Ashrafb commited on
Commit
7827f71
1 Parent(s): 77ae97f

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +342 -24
static/index.html CHANGED
@@ -4,54 +4,372 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Image Enhancement</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
- <h1>Image Enhancement</h1>
10
  <form id="upload-form" enctype="multipart/form-data">
11
- <label for="image">Select an image:</label>
12
- <input type="file" id="image" accept="image/*" required><br><br>
13
 
 
 
 
 
 
 
14
  <label for="version">Select a model version:</label>
15
  <select id="version" required>
16
- <option value="v1.2">GFPGAN v1.2</option>
17
- <option value="v1.3">GFPGAN v1.3</option>
18
- <option value="v1.4">GFPGAN v1.4</option>
19
- <option value="RestoreFormer">RestoreFormer</option>
20
- <option value="CodeFormer">CodeFormer</option>
21
- <option value="RealESR-General-x4v3">RealESR-General-x4v3</option>
22
- </select><br><br>
23
 
24
  <label for="scale">Select scale factor (2 or 4):</label>
25
- <input type="number" id="scale" min="2" max="4" value="4" required><br><br>
26
 
27
  <button type="button" onclick="uploadImage()">Enhance Image</button>
28
  </form>
29
 
30
- <div id="result-container"></div>
 
 
 
 
31
 
32
  <script>
 
 
 
 
 
 
33
  async function uploadImage() {
34
  const fileInput = document.getElementById('image');
35
  const versionInput = document.getElementById('version');
36
  const scaleInput = document.getElementById('scale');
37
 
 
 
 
 
 
 
 
 
 
38
  const formData = new FormData();
39
  formData.append('file', fileInput.files[0]);
40
  formData.append('version', versionInput.value);
41
  formData.append('scale', scaleInput.value);
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- const response = await fetch('/upload/', {
44
- method: 'POST',
45
- body: formData
46
- });
47
-
48
- if (response.ok) {
49
- const resultContainer = document.getElementById('result-container');
50
- const blob = await response.blob();
51
- const imageURL = URL.createObjectURL(blob);
52
- resultContainer.innerHTML = `<img src="${imageURL}" alt="Enhanced Image">`;
53
- } else {
54
- alert('Failed to enhance the image.');
 
 
55
  }
56
  }
57
  </script>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Image Enhancement</title>
7
+ <style>
8
+ body {
9
+ background-color: #121212;
10
+ color: #FFFFFF;
11
+ }
12
+
13
+ /* Dark mode for upload buttons */
14
+ #upload-form button[type="button"] {
15
+ background-color: #1E7E34;
16
+ }
17
+
18
+ /* Dark mode for file input labels */
19
+ .uploadLabel {
20
+ background-color: #BF2C25;
21
+ }
22
+
23
+ /* Dark mode for face number inputs */
24
+ #scale {
25
+ background-color: #333333;
26
+ color: #FFFFFF;
27
+ border: 1px solid #555555;
28
+ }
29
+
30
+ /* Dark mode for swap button */
31
+ button[type="button"] {
32
+ background-color: #1E7E34;
33
+ }
34
+
35
+ /* Dark mode hover effect for swap button */
36
+ button[type="button"]:hover {
37
+ background-color: #2E9E44;
38
+ }
39
+
40
+ /* Style for upload buttons */
41
+ input[type="file"] {
42
+ display: none; /* Hide the default file input */
43
+ }
44
+ #upload-form label[for="image"] {
45
+ padding: 10px 20px;
46
+ background-color: #f44336;
47
+ color: white;
48
+ border-radius: 5px;
49
+ cursor: pointer;
50
+ display: inline-block;
51
+ margin: 0 auto;
52
+ }
53
+
54
+ .uploadButton {
55
+ background-color: #4CAF50;
56
+ border: none;
57
+ color: white;
58
+ padding: 10px 20px;
59
+ text-align: center;
60
+ text-decoration: none;
61
+ display: inline-block;
62
+ font-size: 16px;
63
+ margin-top: 10px;
64
+ cursor: pointer;
65
+ border-radius: 5px;
66
+ margin: auto;
67
+ margin: 0 auto;
68
+ }
69
+
70
+ /* Style for file input labels */
71
+ #upload-form {
72
+ display: flex;
73
+ flex-direction: column;
74
+ align-items: center;
75
+ }
76
+
77
+ .uploadLabel {
78
+ padding: 10px 20px;
79
+ background-color: #f44336;
80
+ color: white;
81
+ border-radius: 5px;
82
+ cursor: pointer;
83
+ display: block;
84
+ margin: 0 auto;
85
+ }
86
+
87
+ .uploadLabel input[type="file"] {
88
+ display: none;
89
+ }
90
+
91
+ /* Style for face number inputs */
92
+ #version, #scale {
93
+ padding: 8px;
94
+ Width :50px;
95
+ border: 1px solid #ccc;
96
+ border-radius: 4px;
97
+ box-sizing: border-box;
98
+ margin-top: 5px;
99
+ font-size: 16px;
100
+ }
101
+
102
+ /* Style for labels */
103
+ label {
104
+ font-weight: bold;
105
+ }
106
+
107
+ /* Optional: Increase space between elements */
108
+ form > * {
109
+ margin-bottom: 10px;
110
+ }
111
+
112
+ /* Style for the swap button */
113
+ button {
114
+ background-image: linear-gradient(
115
+ 45deg,
116
+ hsl(240deg 75% 29%) 0%,
117
+ hsl(254deg 78% 28%) 6%,
118
+ hsl(264deg 82% 27%) 13%,
119
+ hsl(272deg 87% 26%) 19%,
120
+ hsl(278deg 93% 25%) 25%,
121
+ hsl(284deg 98% 24%) 31%,
122
+ hsl(289deg 100% 23%) 37%,
123
+ hsl(294deg 100% 23%) 44%,
124
+ hsl(299deg 100% 22%) 50%,
125
+ hsl(303deg 100% 23%) 56%,
126
+ hsl(307deg 100% 24%) 63%,
127
+ hsl(311deg 100% 25%) 69%,
128
+ hsl(313deg 100% 26%) 75%,
129
+ hsl(316deg 95% 28%) 81%,
130
+ hsl(320deg 88% 30%) 87%,
131
+ hsl(323deg 81% 32%) 94%,
132
+ hsl(326deg 75% 33%) 100%
133
+ );
134
+ border: none;
135
+ color: white;
136
+ padding: 10px 20px;
137
+ text-align: center;
138
+ text-decoration: none;
139
+ display: inline-block;
140
+ font-size: 16px;
141
+ margin-top: 10px;
142
+ cursor: pointer;
143
+ border-radius: 5px;
144
+ display: block;
145
+ margin: 0 auto;
146
+ width: 200px;
147
+ }
148
+
149
+ /* Hover effect for the button */
150
+ button:hover {
151
+ background-color: #45a049;
152
+ }
153
+ /* Style for file input */
154
+ #image {
155
+ display: none; /* Hide the default file input */
156
+ }
157
+
158
+ .uploadLabel {
159
+ padding: 10px 20px;
160
+ background-color: #f44336;
161
+ color: white;
162
+ border-radius: 5px;
163
+ cursor: pointer;
164
+ display: inline-block;
165
+ margin: 0 auto;
166
+ }
167
+
168
+ .uploadLabel input[type="file"] {
169
+ display: none;
170
+ }
171
+
172
+ h1 {
173
+ text-align: center;
174
+ margin-bottom: 20px;
175
+ font-family: 'Barlow Condensed';
176
+ color: pink;
177
+ font-size: 40px; /* Adjust the font size as needed */
178
+ }
179
+
180
+ h2 {
181
+ font-size: 24px; /* Adjust size as needed */
182
+ font-family: 'Barlow Condensed';
183
+ color: #FFFFFF; /* Text color */
184
+ margin-top: 20px; /* Top margin */
185
+ margin-bottom: 10px; /* Bottom margin */
186
+ }
187
+
188
+ select {
189
+ width: 150px; /* Adjust width as needed */
190
+ padding: 8px;
191
+ border: 1px solid #ccc;
192
+ border-radius: 4px;
193
+ background-color: #333333; /* Background color */
194
+ color: white; /* Text color */
195
+ font-size: 16px;
196
+ }
197
+
198
+ /* Style for the scale number input */
199
+ input[type="number"]#scale {
200
+ padding: 8px;
201
+ width: 50px;
202
+ border: 1px solid #ccc;
203
+ border-radius: 4px;
204
+ box-sizing: border-box;
205
+ margin-top: 5px;
206
+ font-size: 16px;
207
+ color: white; /* Set text color to white */
208
+ background-color: #333333; /* Set background color */
209
+ }
210
+
211
+ /* Optional: Adjust focus styling for the scale number input */
212
+ input[type="number"]#scale:focus {
213
+ outline: none; /* Remove default outline */
214
+ border-color: #1E7E34; /* Change border color on focus */
215
+ }
216
+
217
+ #estimatedTime {
218
+ display: none;
219
+ text-align: center; /* Center align the text */
220
+ margin-top: 10px; /* Add margin to separate it from the spinner */
221
+ color: white; /* Set text color */
222
+ }
223
+
224
+ #resultImage {
225
+ border: 2px solid blue;
226
+ width: 265px;
227
+ height: 300px;
228
+ display: flex;
229
+ flex-direction: column;
230
+ overflow-y: scroll;
231
+ margin: auto;
232
+ margin-top: 30px;
233
+ padding-bottom: 7px;
234
+ gap: 14px;
235
+ background: linear-gradient(black , black) padding-box,
236
+ linear-gradient(to right, red, blue) border-box;
237
+ border-radius: 20px;
238
+ border: 2.5px solid transparent;
239
+ }
240
+
241
+
242
+
243
+ #resultContainer img {
244
+ max-width: 100%;
245
+ height: auto;
246
+ display: block;
247
+ margin: auto;
248
+ }
249
+ #image-preview {
250
+ border: 2px solid blue;
251
+ width: 200px;
252
+ height: 200px;
253
+ display: flex;
254
+ flex-direction: column;
255
+ overflow-y: scroll;
256
+ margin: auto;
257
+ margin-top: 30px;
258
+ padding-bottom: 7px;
259
+ gap: 100px;
260
+ background: linear-gradient(black , black) padding-box,
261
+ linear-gradient(to right, red, blue) border-box;
262
+ border-radius: 20px;
263
+ border: 2.5px solid transparent;
264
+ }
265
+
266
+ #sourceImage {
267
+ max-width: 100%;
268
+ height: auto;
269
+ display: block;
270
+ margin: auto;
271
+ }
272
+ #loadingSpinner {
273
+ border: 3px solid rgba(255, 255, 255, 0.3);
274
+ border-radius: 50%;
275
+ border-top: 5px solid #ffffff;
276
+ width: 20px;
277
+ height: 20px;
278
+ animation: spin 2s linear infinite;
279
+ position: relative;
280
+ top: 50%;
281
+ left: 50%;
282
+ transform: translate(-50%, -50%);
283
+ display: none; /* Initially hide the loading spinner */
284
+ }
285
+
286
+ @keyframes spin {
287
+ 0% { transform: rotate(0deg); }
288
+ 100% { transform: rotate(360deg); }
289
+ }
290
+ </style>
291
  </head>
292
  <body>
293
+ <h1>Aiconvert.online</h1>
294
  <form id="upload-form" enctype="multipart/form-data">
 
 
295
 
296
+ <label for="image">Select image:</label>
297
+ <input type="file" id="image" accept="image/*" required onchange="previewImage(event)">
298
+ <div id="image-preview">
299
+
300
+ <img id="sourceImage">
301
+ </div><br>
302
  <label for="version">Select a model version:</label>
303
  <select id="version" required>
304
+ <option value="v1.2">M1</option>
305
+ <option value="v1.3">M2</option>
306
+ <option value="v1.4">M3</option>
307
+
308
+ </select><br>
 
 
309
 
310
  <label for="scale">Select scale factor (2 or 4):</label>
311
+ <input type="number" id="scale" min="2" max="4" value="4" required><br>
312
 
313
  <button type="button" onclick="uploadImage()">Enhance Image</button>
314
  </form>
315
 
316
+ <div id="resultImage">
317
+ <div id="estimatedTime" style="display: none;">Estimated time: 90s</div>
318
+ <div id="loadingSpinner" style="display: none;"></div>
319
+ <div id="resultContainer"></div>
320
+ </div>
321
 
322
  <script>
323
+ function previewImage(event) {
324
+ const file = event.target.files[0];
325
+ const imagePreview = document.getElementById('image-preview');
326
+ imagePreview.innerHTML = `<img src="${URL.createObjectURL(file)}" alt="Uploaded Image" style="max-width: 300px; max-height: 300px;">`;
327
+ }
328
+
329
  async function uploadImage() {
330
  const fileInput = document.getElementById('image');
331
  const versionInput = document.getElementById('version');
332
  const scaleInput = document.getElementById('scale');
333
 
334
+ // Check if the file input is empty
335
+ if (!fileInput.files[0]) {
336
+ document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Please upload an image.</p>`;
337
+ return;
338
+ }
339
+
340
+ // Clear the result container
341
+ document.getElementById('resultContainer').innerHTML = "";
342
+
343
  const formData = new FormData();
344
  formData.append('file', fileInput.files[0]);
345
  formData.append('version', versionInput.value);
346
  formData.append('scale', scaleInput.value);
347
+
348
+ // Display loading spinner
349
+ const loadingSpinner = document.getElementById('loadingSpinner');
350
+ loadingSpinner.style.display = 'block';
351
+ const estimatedTime = document.getElementById('estimatedTime');
352
+ estimatedTime.style.display = 'block';
353
+ try {
354
+ const response = await fetch('/upload/', {
355
+ method: 'POST',
356
+ body: formData
357
+ });
358
 
359
+ // Hide loading spinner
360
+ loadingSpinner.style.display = 'none';
361
+ estimatedTime.style.display = 'none';
362
+ if (response.ok) {
363
+ const resultContainer = document.getElementById('resultContainer');
364
+ const blob = await response.blob();
365
+ const imageURL = URL.createObjectURL(blob);
366
+ resultContainer.innerHTML = `<img src="${imageURL}" alt="Enhanced Image">`;
367
+ } else {
368
+ document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
369
+ }
370
+ } catch (error) {
371
+ console.error('Error:', error);
372
+ document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
373
  }
374
  }
375
  </script>