Ashrafb commited on
Commit
2e11f0f
·
verified ·
1 Parent(s): f9294c6

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +34 -428
static/index.html CHANGED
@@ -3,440 +3,46 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
7
- <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
8
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
9
- <style>
10
- body {
11
- background-color: #121212;
12
- color: #FFFFFF;
13
- }
14
-
15
- /* Dark mode for upload buttons */
16
- #upload-form button[type="button"] {
17
- background-color: #1E7E34;
18
- }
19
-
20
- /* Dark mode for file input labels */
21
- #image-label {
22
- background-color: #BF2C25;
23
- }
24
-
25
- /* Dark mode for face number inputs */
26
- #best_max_flavors {
27
- background-color: #333333;
28
- color: #FFFFFF;
29
- border: 1px solid #555555;
30
- }
31
-
32
- /* Dark mode for swap button */
33
- button[type="button"] {
34
- background-color: #1E7E34;
35
- }
36
-
37
- /* Dark mode hover effect for swap button */
38
- button[type="button"]:hover {
39
- background-color: #2E9E44;
40
- }
41
-
42
- /* Style for upload buttons */
43
- input[type="file"] {
44
- display: none; /* Hide the default file input */
45
- }
46
- #upload-form label[for="image"] {
47
- padding: 10px 20px;
48
- background-color: #f44336;
49
- color: white;
50
- border-radius: 5px;
51
- cursor: pointer;
52
- display: inline-block;
53
- margin: 0 auto;
54
- }
55
- #image-label {
56
- padding: 10px 20px;
57
- background-color: #f44336;
58
- color: white;
59
- border-radius: 5px;
60
- cursor: pointer;
61
- display: inline-block;
62
- margin: 0 auto;
63
- }
64
-
65
- .uploadButton {
66
- background-color: #4CAF50;
67
- border: none;
68
- color: white;
69
- padding: 10px 20px;
70
- text-align: center;
71
- text-decoration: none;
72
- display: inline-block;
73
- font-size: 16px;
74
- margin-top: 10px;
75
- cursor: pointer;
76
- border-radius: 5px;
77
- margin: auto;
78
- margin: 0 auto;
79
- }
80
-
81
- /* Style for file input labels */
82
- #upload-form {
83
- display: flex;
84
- flex-direction: column;
85
- align-items: center;
86
- }
87
-
88
- #image-label {
89
- padding: 10px 20px;
90
- background-color: #f44336;
91
- color: white;
92
- border-radius: 5px;
93
- cursor: pointer;
94
- display: block;
95
- margin: 0 auto;
96
- }
97
-
98
- #image-label input[type="file"] {
99
- display: none;
100
- }
101
-
102
- /* Style for face number inputs */
103
- #mode, #best_max_flavors {
104
- padding: 8px;
105
- border: 1px solid #ccc;
106
- border-radius: 4px;
107
- box-sizing: border-box;
108
- margin-top: 5px;
109
- font-size: 16px;
110
- }
111
-
112
- /* Style for labels */
113
- label {
114
- font-weight: bold;
115
- }
116
-
117
- /* Optional: Increase space between elements */
118
- form > * {
119
- margin-bottom: 10px;
120
- }
121
-
122
- /* Style for the swap button */
123
- button {
124
- background-image: linear-gradient(
125
- 45deg,
126
- hsl(240deg 75% 29%) 0%,
127
- hsl(254deg 78% 28%) 6%,
128
- hsl(264deg 82% 27%) 13%,
129
- hsl(272deg 87% 26%) 19%,
130
- hsl(278deg 93% 25%) 25%,
131
- hsl(284deg 98% 24%) 31%,
132
- hsl(289deg 100% 23%) 37%,
133
- hsl(294deg 100% 23%) 44%,
134
- hsl(299deg 100% 22%) 50%,
135
- hsl(303deg 100% 23%) 56%,
136
- hsl(307deg 100% 24%) 63%,
137
- hsl(311deg 100% 25%) 69%,
138
- hsl(313deg 100% 26%) 75%,
139
- hsl(316deg 95% 28%) 81%,
140
- hsl(320deg 88% 30%) 87%,
141
- hsl(323deg 81% 32%) 94%,
142
- hsl(326deg 75% 33%) 100%
143
- );
144
- border: none;
145
- color: white;
146
- padding: 10px 20px;
147
- text-align: center;
148
- text-decoration: none;
149
- display: inline-block;
150
- font-size: 16px;
151
- margin-top: 10px;
152
- cursor: pointer;
153
- border-radius: 5px;
154
- display: block;
155
- margin: 0 auto;
156
- width: 200px;
157
- }
158
-
159
- /* Hover effect for the button */
160
- button:hover {
161
- background-color: #45a049;
162
- }
163
-
164
- /* Style for file input */
165
- #image {
166
- display: none; /* Hide the default file input */
167
- }
168
-
169
- #image-label {
170
- padding: 10px 20px;
171
- background-color: #f44336;
172
- color: white;
173
- border-radius: 5px;
174
- cursor: pointer;
175
- display: inline-block;
176
- margin: 0 auto;
177
- }
178
-
179
- #image-label input[type="file"] {
180
- display: none;
181
- }
182
-
183
- h1 {
184
- text-align: center;
185
- margin-bottom: 20px;
186
- font-family: 'Barlow Condensed';
187
- color: pink;
188
- font-size: 40px; /* Adjust the font size as needed */
189
- }
190
-
191
- h2 {
192
- font-size: 24px; /* Adjust size as needed */
193
- font-family: 'Barlow Condensed';
194
- color: #FFFFFF; /* Text color */
195
- margin-top: 20px; /* Top margin */
196
- margin-bottom: 10px; /* Bottom margin */
197
- }
198
-
199
- select {
200
- width: 150px; /* Adjust width as needed */
201
- padding: 8px;
202
- border: 1px solid #ccc;
203
- border-radius: 4px;
204
- background-color: #333333; /* Background color */
205
- color: white; /* Text color */
206
- font-size: 16px;
207
- }
208
-
209
- #best_max_flavors {
210
- width: 60px;
211
- }
212
-
213
- /* Style for the scale number input */
214
- input[type="number"]#best_max_flavors {
215
- padding: 8px;
216
- width: 50px;
217
- border: 1px solid #ccc;
218
- border-radius: 4px;
219
- box-sizing: border-box;
220
- margin-top: 5px;
221
- font-size: 16px;
222
- color: white; /* Set text color to white */
223
- background-color: #333333; /* Set background color */
224
- }
225
-
226
- /* Optional: Adjust focus styling for the scale number input */
227
- input[type="number"]#best_max_flavors:focus {
228
- outline: none; /* Remove default outline */
229
- border-color: #1E7E34; /* Change border color on focus */
230
- }
231
-
232
- #estimatedTime {
233
- display: none;
234
- text-align: center; /* Center align the text */
235
- margin-top: 10px; /* Add margin to separate it from the spinner */
236
- color: white; /* Set text color */
237
- }
238
-
239
- #results {
240
- border: 2px solid blue;
241
- width: 265px;
242
- height: 300px;
243
- display: flex;
244
- flex-direction: column;
245
- overflow-y: scroll;
246
- margin: auto;
247
- margin-top: 30px;
248
- padding-bottom: 7px;
249
- gap: 14px;
250
- background: linear-gradient(black , black) padding-box,
251
- linear-gradient(to right, red, blue) border-box;
252
- border-radius: 20px;
253
- border: 2.5px solid transparent;
254
- }
255
-
256
- #image-preview {
257
- border: 2px solid blue;
258
- width: 200px;
259
- height: 200px;
260
- display: flex;
261
- flex-direction: column;
262
- overflow-y: scroll;
263
- margin: auto;
264
- margin-top: 30px;
265
- padding-bottom: 7px;
266
- gap: 100px;
267
- background: linear-gradient(black , black) padding-box,
268
- linear-gradient(to right, red, blue) border-box;
269
- border-radius: 20px;
270
- border: 2.5px solid transparent;
271
- }
272
-
273
- #sourceImage {
274
- max-width: 100%;
275
- height: auto;
276
- display: block;
277
- margin: auto;
278
- }
279
-
280
- #loadingSpinner {
281
- border: 3px solid rgba(255, 255, 255, 0.3);
282
- border-radius: 50%;
283
- border-top: 3px solid #ffffff;
284
- width: 20px;
285
- height: 20px;
286
- animation: spin 2s linear infinite;
287
- position: relative;
288
- top: 50%;
289
- left: 50%;
290
- transform: translate(-50%, -50%);
291
- display: none; /* Initially hide the loading spinner */
292
- }
293
-
294
- @keyframes spin {
295
- 0% { transform: rotate(0deg); }
296
- 100% { transform: rotate(360deg); }
297
- }
298
- #results {
299
- position: relative; /* Set position to relative */
300
- /* Your existing styles */
301
- }
302
-
303
- #copyIcon {
304
- font-size: 24px; /* Adjust the font size as needed */
305
- position: absolute;
306
- bottom: 10px; /* Adjust the distance from the bottom */
307
- left: 10px; /* Adjust the distance from the left */
308
- cursor: pointer;
309
- z-index: 1;
310
- color: rgba(255, 255, 255, 0.7); /* Adjust the opacity value */
311
- }
312
- #resultContainer {
313
- /* Include padding and border in the total height */
314
- }
315
-
316
- #resultContainer p {
317
- font-size: 14px; /* Adjust the font size as needed */
318
- text-align: center; /* Center text horizontally */
319
- margin: 5px 0; /* Add margin for spacing between paragraphs */
320
- line-height: 1.5; /* Adjust line height for better readability */
321
- }
322
-
323
-
324
- </style>
325
-
326
  </head>
327
  <body>
328
- <h1>Aiconvert.online</h1>
329
- <form id="upload-form" enctype="multipart/form-data">
330
- <label for="image">Select image:</label>
331
- <input type="file" id="image" accept="image/*" required onchange="previewImage(event)">
332
- <div id="image-preview">
333
-
334
- <img id="sourceImage">
335
- </div><br>
336
-
337
- <button type="button" onclick="generateDescription()">Generate Description</button>
338
  </form>
339
- <div id="results">
340
- <div id="estimatedTime" style="display: none;">Estimated time: 90s</div>
341
- <div id="loadingSpinner" style="display: none;"></div>
342
- <i class="far fa-copy" id="copyIcon" onclick="copyTextToClipboard()"></i>
343
- <div id="resultContainer">
344
- </div>
345
- </div>
346
- <script>
347
- function previewImage(event) {
348
- const file = event.target.files[0];
349
- const sourceImageContainer = document.getElementById('image-preview');
350
- const uploadButton = document.querySelector('button');
351
-
352
- // Check if file size is larger than 500 KB
353
- if (file.size > 1000 * 1024) {
354
- sourceImageContainer.innerHTML = `<p style="color: white;">Please upload an image smaller than 1000 KB.</p>`;
355
- uploadButton.disabled = true; // Disable the button
356
- return;
357
- }
358
 
359
- // If file size is within limit, display image preview
360
- const reader = new FileReader();
361
- reader.onload = function(event) {
362
- sourceImageContainer.innerHTML = `<img src="${event.target.result}" alt="Uploaded Image" style="max-width: 300px; max-height: 300px;">`;
363
- };
364
- reader.readAsDataURL(file);
365
- uploadButton.disabled = false; // Enable the button
366
- }
367
-
368
- async function generateDescription() {
369
- var formData = new FormData();
370
- var fileInput = document.querySelector('input[type="file"]');
371
- formData.append("file", fileInput.files[0]);
372
- // Check if the file input is empty
373
- if (!fileInput.files[0]) {
374
- document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Please upload an image.</p>`;
375
- return;
376
- }
377
-
378
- // Clear the result container
379
- document.getElementById('resultContainer').innerHTML = "";
380
- // Display loading spinner
381
- const loadingSpinner = document.getElementById('loadingSpinner');
382
- loadingSpinner.style.display = 'block';
383
- const estimatedTime = document.getElementById('estimatedTime');
384
- estimatedTime.style.display = 'block';
385
 
386
- try {
387
- const response = await fetch('/uploadfile/', {
388
- method: 'POST',
389
- body: formData
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  });
391
- // Hide loading spinner
392
- loadingSpinner.style.display = 'none';
393
- estimatedTime.style.display = 'none';
394
-
395
- if (response.ok) {
396
- const resultContainer = document.getElementById('resultContainer');
397
- const data = await response.text(); // Get response as text
398
- resultContainer.innerHTML = '<h2></h2>';
399
- resultContainer.innerText = data; // Set response text to innerText
400
-
401
- } else {
402
- document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
403
- }
404
- } catch (error) {
405
- console.error('Error:', error);
406
- document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Oops! Something went wrong. Please try again later.</p>`;
407
- }
408
- }
409
- function copyTextToClipboard() {
410
- const resultContainer = document.getElementById('resultContainer');
411
- const textToCopy = resultContainer.innerText;
412
-
413
- // Create a temporary textarea element to copy the text
414
- const textarea = document.createElement('textarea');
415
- textarea.value = textToCopy;
416
- document.body.appendChild(textarea);
417
-
418
- // Select the text inside the textarea
419
- textarea.select();
420
- textarea.setSelectionRange(0, 99999); // For mobile devices
421
-
422
- // Copy the selected text
423
- document.execCommand('copy');
424
-
425
- // Remove the temporary textarea
426
- document.body.removeChild(textarea);
427
-
428
- // Change the copy icon text to "Copied"
429
- const copyIcon = document.getElementById('copyIcon');
430
- copyIcon.textContent = ' # Copied' ;
431
- copyIcon.style.fontSize = '14px';
432
- // Revert the copy icon back to "Copy" after 1.5 seconds
433
- setTimeout(() => {
434
- copyIcon.textContent = '';
435
- }, 1500);
436
- }
437
-
438
-
439
-
440
  </script>
441
  </body>
442
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Image Captioning</title>
7
+ <style>
8
+ .result {
9
+ margin-top: 20px;
10
+ }
11
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </head>
13
  <body>
14
+ <h1>Image Captioning</h1>
15
+ <form id="uploadForm" action="/uploadfile/" method="post" enctype="multipart/form-data">
16
+ <label for="image">Upload Image:</label><br>
17
+ <input type="file" id="image" name="image" accept="image/*"><br>
18
+ <label for="context">Additional Context:</label><br>
19
+ <textarea id="context" name="context" rows="4" cols="50"></textarea><br>
20
+ <button type="submit">Submit</button>
 
 
 
21
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ <div id="result" class="result" style="display: none;">
24
+ <h2>Result:</h2>
25
+ <p id="caption"></p>
26
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ <script>
29
+ document.getElementById('uploadForm').addEventListener('submit', async function(event) {
30
+ event.preventDefault();
31
+
32
+ let formData = new FormData(this);
33
+ let response = await fetch('/uploadfile/', {
34
+ method: 'POST',
35
+ body: formData
36
+ });
37
+
38
+ if (response.ok) {
39
+ let result = await response.json();
40
+ document.getElementById('caption').innerText = result.result;
41
+ document.getElementById('result').style.display = 'block';
42
+ } else {
43
+ alert('An error occurred while processing the request.');
44
+ }
45
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  </script>
47
  </body>
48
  </html>