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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<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 |
+
<label for="question" style="display: none;">Enter your question:</label>
|
337 |
+
<input type="text" id="Question" style="display: none;" value="Describe this image in detail" required>
|
338 |
+
<br>
|
339 |
+
<button type="button" onclick="generateDescription()">Generate Description</button>
|
340 |
+
</form>
|
341 |
+
<div id="results">
|
342 |
+
<div id="estimatedTime" style="display: none;">Estimated time: 90s</div>
|
343 |
+
<div id="loadingSpinner" style="display: none;"></div>
|
344 |
+
<i class="far fa-copy" id="copyIcon" onclick="copyTextToClipboard()"></i>
|
345 |
+
<div id="resultContainer">
|
346 |
+
</div>
|
347 |
+
</div>
|
348 |
+
<script>
|
349 |
+
function previewImage(event) {
|
350 |
+
const file = event.target.files[0];
|
351 |
+
const sourceImageContainer = document.getElementById('image-preview');
|
352 |
+
const uploadButton = document.querySelector('button');
|
353 |
+
|
354 |
+
// Check if file size is larger than 500 KB
|
355 |
+
if (file.size > 4000 * 1024) {
|
356 |
+
sourceImageContainer.innerHTML = `<p style="color: white;">Please upload an image smaller than 4000 KB.</p>`;
|
357 |
+
uploadButton.disabled = true; // Disable the button
|
358 |
+
return;
|
359 |
+
}
|
360 |
+
|
361 |
+
// If file size is within limit, display image preview
|
362 |
+
const reader = new FileReader();
|
363 |
+
reader.onload = function(event) {
|
364 |
+
sourceImageContainer.innerHTML = `<img src="${event.target.result}" alt="Uploaded Image" style="max-width: 300px; max-height: 300px;">`;
|
365 |
+
};
|
366 |
+
reader.readAsDataURL(file);
|
367 |
+
uploadButton.disabled = false; // Enable the button
|
368 |
+
}
|
369 |
+
|
370 |
+
async function generateDescription() {
|
371 |
+
var formData = new FormData();
|
372 |
+
var fileInput = document.querySelector('input[type="file"]');
|
373 |
+
const QuestionInput = document.getElementById('Question');
|
374 |
+
formData.append("file", fileInput.files[0]);
|
375 |
+
formData.append("Question", QuestionInput.value);
|
376 |
+
// Check if the file input is empty
|
377 |
+
if (!fileInput.files[0]) {
|
378 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Please upload an image.</p>`;
|
379 |
+
return;
|
380 |
+
}
|
381 |
+
|
382 |
+
// Clear the result container
|
383 |
+
document.getElementById('resultContainer').innerHTML = "";
|
384 |
+
// Display loading spinner
|
385 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
386 |
+
loadingSpinner.style.display = 'block';
|
387 |
+
const estimatedTime = document.getElementById('estimatedTime');
|
388 |
+
estimatedTime.style.display = 'block';
|
389 |
+
|
390 |
+
try {
|
391 |
+
const response = await fetch('/upload/', {
|
392 |
+
method: 'POST',
|
393 |
+
body: formData
|
394 |
+
});
|
395 |
+
// Hide loading spinner
|
396 |
+
loadingSpinner.style.display = 'none';
|
397 |
+
estimatedTime.style.display = 'none';
|
398 |
+
|
399 |
+
if (response.ok) {
|
400 |
+
const resultContainer = document.getElementById('resultContainer');
|
401 |
+
const data = await response.text(); // Get response as text
|
402 |
+
resultContainer.innerHTML = '<h2></h2>';
|
403 |
+
resultContainer.innerText = data; // Set response text to innerText
|
404 |
+
|
405 |
+
} else {
|
406 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
|
407 |
+
}
|
408 |
+
} catch (error) {
|
409 |
+
console.error('Error:', error);
|
410 |
+
document.getElementById('resultContainer').innerHTML = `<p style="color: white ;">Oops! Something went wrong. Please try again later.</p>`;
|
411 |
+
}
|
412 |
+
}
|
413 |
+
function copyTextToClipboard() {
|
414 |
+
const resultContainer = document.getElementById('resultContainer');
|
415 |
+
const textToCopy = resultContainer.innerText;
|
416 |
+
|
417 |
+
// Create a temporary textarea element to copy the text
|
418 |
+
const textarea = document.createElement('textarea');
|
419 |
+
textarea.value = textToCopy;
|
420 |
+
document.body.appendChild(textarea);
|
421 |
+
|
422 |
+
// Select the text inside the textarea
|
423 |
+
textarea.select();
|
424 |
+
textarea.setSelectionRange(0, 99999); // For mobile devices
|
425 |
+
|
426 |
+
// Copy the selected text
|
427 |
+
document.execCommand('copy');
|
428 |
+
|
429 |
+
// Remove the temporary textarea
|
430 |
+
document.body.removeChild(textarea);
|
431 |
+
|
432 |
+
// Change the copy icon text to "Copied"
|
433 |
+
const copyIcon = document.getElementById('copyIcon');
|
434 |
+
copyIcon.textContent = ' # Copied' ;
|
435 |
+
copyIcon.style.fontSize = '14px';
|
436 |
+
// Revert the copy icon back to "Copy" after 1.5 seconds
|
437 |
+
setTimeout(() => {
|
438 |
+
copyIcon.textContent = '';
|
439 |
+
}, 1500);
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
|
444 |
+
</script>
|
445 |
+
</body>
|
446 |
+
</html>
|