Timilehin commited on
Commit
1d5a407
·
verified ·
1 Parent(s): 49ce275

Upload 2 files

Browse files
Files changed (2) hide show
  1. templates/anchor.html +59 -0
  2. templates/index.html +208 -0
templates/anchor.html ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Garment Processing</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/css/bootstrap.min.css">
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1 class="mt-5">Garment Processing</h1>
12
+ <form id="processForm" class="mt-4">
13
+ <div class="mb-3">
14
+ <label for="filename" class="form-label">Upload Image</label>
15
+ <input class="form-control" type="file" id="filename" accept="image/*" required>
16
+ </div>
17
+ <button type="submit" class="btn btn-primary">Process Garment</button>
18
+ </form>
19
+
20
+ <div id="result" class="mt-4"></div>
21
+ </div>
22
+
23
+ <script>
24
+ document.getElementById('processForm').addEventListener('submit', function(event) {
25
+ event.preventDefault();
26
+
27
+ let formData = new FormData();
28
+ let fileInput = document.getElementById('filename').files[0];
29
+
30
+ formData.append('file', fileInput); // Append the file to the form data
31
+
32
+ fetch('/process', {
33
+ method: 'POST',
34
+ body: formData // Send the form data directly
35
+ })
36
+ .then(response => {
37
+ if (response.ok) {
38
+ return response.blob();
39
+ } else {
40
+ return response.json().then(err => {throw new Error(err.error);});
41
+ }
42
+ })
43
+ .then(blob => {
44
+ let url = window.URL.createObjectURL(blob);
45
+ let a = document.createElement('a');
46
+ a.href = url;
47
+ a.download = "processed_output.ply";
48
+ document.getElementById('result').innerHTML = "Download the processed file: ";
49
+ a.textContent = "Download";
50
+ document.getElementById('result').appendChild(a);
51
+ })
52
+ .catch(error => {
53
+ console.error('Error:', error);
54
+ document.getElementById('result').textContent = "An error occurred during processing: " + error.message;
55
+ });
56
+ });
57
+ </script>
58
+ </body>
59
+ </html>
templates/index.html ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Garment and Human Mesh Processing</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/css/bootstrap.min.css">
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ background-color: #f4f4f4;
12
+ margin: 0;
13
+ padding: 20px;
14
+ }
15
+ h1 {
16
+ color: #333;
17
+ }
18
+ form {
19
+ background-color: #fff;
20
+ padding: 20px;
21
+ border-radius: 5px;
22
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
23
+ margin-bottom: 20px;
24
+ }
25
+ input[type="file"] {
26
+ margin-bottom: 10px;
27
+ }
28
+ button {
29
+ background-color: #007bff;
30
+ color: #fff;
31
+ border: none;
32
+ padding: 10px 20px;
33
+ cursor: pointer;
34
+ border-radius: 5px;
35
+ }
36
+ button:hover {
37
+ background-color: #0056b3;
38
+ }
39
+ #result, #loading-indicator {
40
+ margin-top: 20px;
41
+ }
42
+ #download-link {
43
+ display: none;
44
+ margin-top: 20px;
45
+ }
46
+ #loading-indicator, #garment-loading-indicator {
47
+ display: none;
48
+ font-size: 16px;
49
+ color: #007bff;
50
+ }
51
+ .spinner {
52
+ border: 4px solid rgba(0, 0, 0, 0.1);
53
+ border-left: 4px solid #007bff;
54
+ border-radius: 50%;
55
+ width: 24px;
56
+ height: 24px;
57
+ animation: spin 1s linear infinite;
58
+ display: inline-block;
59
+ vertical-align: middle;
60
+ margin-right: 8px;
61
+ }
62
+ @keyframes spin {
63
+ 0% { transform: rotate(0deg); }
64
+ 100% { transform: rotate(360deg); }
65
+ }
66
+ .section-divider {
67
+ height: 2px;
68
+ background-color: #ccc;
69
+ margin: 40px 0;
70
+ }
71
+ </style>
72
+ </head>
73
+ <body>
74
+
75
+ <div class="container">
76
+ <h1 class="mt-5">Garment and Human Mesh Processing</h1>
77
+
78
+ <!-- Garment Processing Section -->
79
+ <section>
80
+ <h2 class="mt-4">Garment Processing</h2>
81
+ <form id="processForm" class="mt-4">
82
+ <div class="mb-3">
83
+ <label for="filename" class="form-label">Upload Image</label>
84
+ <input class="form-control" type="file" id="filename" accept="image/*" required>
85
+ </div>
86
+ <button type="submit" class="btn btn-primary">Process Garment</button>
87
+ </form>
88
+ <div id="garment-loading-indicator">
89
+ <div class="spinner"></div>
90
+ Processing...
91
+ </div>
92
+ <div id="result" class="mt-4"></div>
93
+ </section>
94
+
95
+ <!-- Divider -->
96
+ <div class="section-divider"></div>
97
+
98
+ <!-- Human Mesh Generator Section -->
99
+ <section>
100
+ <h2 class="mt-4">Human Mesh Generator</h2>
101
+ <form id="upload-form">
102
+ <input type="file" id="file-input" name="file" accept="image/*" required>
103
+ <button type="submit" class="btn btn-primary">Generate Mesh</button>
104
+ </form>
105
+
106
+ <div id="loading-indicator">
107
+ <div class="spinner"></div>
108
+ Processing...
109
+ </div>
110
+
111
+ <a id="download-link" class="btn btn-success mt-3">Download Generated OBJ File</a>
112
+ </section>
113
+ </div>
114
+
115
+ <script>
116
+ // Garment Processing Form
117
+ document.getElementById('processForm').addEventListener('submit', function(event) {
118
+ event.preventDefault();
119
+
120
+ // Show loading indicator
121
+ var loadingIndicator = document.getElementById('garment-loading-indicator');
122
+ loadingIndicator.style.display = 'inline-block';
123
+
124
+ let formData = new FormData();
125
+ let fileInput = document.getElementById('filename').files[0];
126
+
127
+ formData.append('file', fileInput);
128
+
129
+ fetch('/process', {
130
+ method: 'POST',
131
+ body: formData
132
+ })
133
+ .then(response => {
134
+ if (response.ok) {
135
+ return response.blob();
136
+ } else {
137
+ return response.json().then(err => {throw new Error(err.error);});
138
+ }
139
+ })
140
+ .then(blob => {
141
+ let url = window.URL.createObjectURL(blob);
142
+ let a = document.createElement('a');
143
+ a.href = url;
144
+ a.download = "processed_output.ply";
145
+ document.getElementById('result').innerHTML = "Download the processed file: ";
146
+ a.textContent = "Download";
147
+ document.getElementById('result').appendChild(a);
148
+
149
+ // Hide loading indicator
150
+ loadingIndicator.style.display = 'none';
151
+ })
152
+ .catch(error => {
153
+ console.error('Error:', error);
154
+ document.getElementById('result').textContent = "An error occurred during processing: " + error.message;
155
+
156
+ // Hide loading indicator in case of error
157
+ loadingIndicator.style.display = 'none';
158
+ });
159
+ });
160
+
161
+ // Human Mesh Generator Form
162
+ document.getElementById('upload-form').addEventListener('submit', function(event) {
163
+ event.preventDefault();
164
+
165
+ // Show loading indicator
166
+ var loadingIndicator = document.getElementById('loading-indicator');
167
+ loadingIndicator.style.display = 'inline-block';
168
+
169
+ var downloadLink = document.getElementById('download-link');
170
+ downloadLink.style.display = 'none';
171
+ downloadLink.href = '';
172
+ downloadLink.textContent = '';
173
+
174
+ var formData = new FormData();
175
+ var fileInput = document.getElementById('file-input');
176
+ formData.append('file', fileInput.files[0]);
177
+
178
+ fetch('/generate-mesh', {
179
+ method: 'POST',
180
+ body: formData
181
+ })
182
+ .then(response => {
183
+ if (!response.ok) {
184
+ throw new Error('Network response was not ok.');
185
+ }
186
+ return response.blob();
187
+ })
188
+ .then(blob => {
189
+ var url = window.URL.createObjectURL(blob);
190
+ downloadLink.href = url;
191
+ downloadLink.download = 'output.obj';
192
+ downloadLink.style.display = 'block';
193
+ downloadLink.textContent = 'Download Generated OBJ File';
194
+
195
+ // Hide loading indicator
196
+ loadingIndicator.style.display = 'none';
197
+ })
198
+ .catch(error => {
199
+ console.error('There was a problem with the fetch operation:', error);
200
+
201
+ // Hide loading indicator in case of error
202
+ loadingIndicator.style.display = 'none';
203
+ });
204
+ });
205
+ </script>
206
+
207
+ </body>
208
+ </html>