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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 |
+
<style>
|
9 |
+
body {
|
10 |
+
background-color: #121212;
|
11 |
+
color: #FFFFFF;
|
12 |
+
}
|
13 |
+
|
14 |
+
/* Dark mode for upload buttons */
|
15 |
+
.uploadButton {
|
16 |
+
background-color: #1E7E34;
|
17 |
+
}
|
18 |
+
|
19 |
+
/* Dark mode for file input labels */
|
20 |
+
.uploadLabel {
|
21 |
+
background-color: #BF2C25;
|
22 |
+
}
|
23 |
+
|
24 |
+
/* Dark mode for face number inputs */
|
25 |
+
input[type="number"] {
|
26 |
+
background-color: #333333;
|
27 |
+
color: #FFFFFF;
|
28 |
+
border: 1px solid #555555;
|
29 |
+
}
|
30 |
+
|
31 |
+
/* Dark mode for swap button */
|
32 |
+
button[type="button"] {
|
33 |
+
background-color: #1E7E34;
|
34 |
+
}
|
35 |
+
|
36 |
+
/* Dark mode hover effect for swap button */
|
37 |
+
button[type="button"]:hover {
|
38 |
+
background-color: #2E9E44;
|
39 |
+
}
|
40 |
+
|
41 |
+
/* Style for upload buttons */
|
42 |
+
input[type="file"] {
|
43 |
+
display: none; /* Hide the default file input */
|
44 |
+
}
|
45 |
+
|
46 |
+
.uploadButton {
|
47 |
+
background-color: #4CAF50;
|
48 |
+
border: none;
|
49 |
+
color: white;
|
50 |
+
padding: 10px 20px;
|
51 |
+
text-align: center;
|
52 |
+
text-decoration: none;
|
53 |
+
display: inline-block;
|
54 |
+
font-size: 16px;
|
55 |
+
margin-top: 10px;
|
56 |
+
cursor: pointer;
|
57 |
+
border-radius: 5px;
|
58 |
+
margin: auto;
|
59 |
+
}
|
60 |
+
|
61 |
+
/* Style for file input labels */
|
62 |
+
#uploadForm {
|
63 |
+
display: flex;
|
64 |
+
flex-direction: column;
|
65 |
+
align-items: center;
|
66 |
+
}
|
67 |
+
|
68 |
+
.uploadLabel {
|
69 |
+
padding: 10px 20px;
|
70 |
+
background-color: #f44336;
|
71 |
+
color: white;
|
72 |
+
border-radius: 5px;
|
73 |
+
cursor: pointer;
|
74 |
+
display: inline-block;
|
75 |
+
}
|
76 |
+
|
77 |
+
.uploadLabel input[type="file"] {
|
78 |
+
display: none;
|
79 |
+
}
|
80 |
+
|
81 |
+
/* Style for face number inputs */
|
82 |
+
input[type="number"] {
|
83 |
+
padding: 8px;
|
84 |
+
Width :50px;
|
85 |
+
border: 1px solid #ccc;
|
86 |
+
border-radius: 4px;
|
87 |
+
box-sizing: border-box;
|
88 |
+
margin-top: 5px;
|
89 |
+
font-size: 16px;
|
90 |
+
}
|
91 |
+
|
92 |
+
/* Style for labels */
|
93 |
+
label {
|
94 |
+
font-weight: bold;
|
95 |
+
}
|
96 |
+
|
97 |
+
/* Optional: Increase space between elements */
|
98 |
+
form > * {
|
99 |
+
margin-bottom: 10px;
|
100 |
+
}
|
101 |
+
/* Style for the swap button */
|
102 |
+
button[type="button"] {
|
103 |
+
background-image: linear-gradient(
|
104 |
+
45deg,
|
105 |
+
hsl(240deg 75% 29%) 0%,
|
106 |
+
hsl(254deg 78% 28%) 6%,
|
107 |
+
hsl(264deg 82% 27%) 13%,
|
108 |
+
hsl(272deg 87% 26%) 19%,
|
109 |
+
hsl(278deg 93% 25%) 25%,
|
110 |
+
hsl(284deg 98% 24%) 31%,
|
111 |
+
hsl(289deg 100% 23%) 37%,
|
112 |
+
hsl(294deg 100% 23%) 44%,
|
113 |
+
hsl(299deg 100% 22%) 50%,
|
114 |
+
hsl(303deg 100% 23%) 56%,
|
115 |
+
hsl(307deg 100% 24%) 63%,
|
116 |
+
hsl(311deg 100% 25%) 69%,
|
117 |
+
hsl(313deg 100% 26%) 75%,
|
118 |
+
hsl(316deg 95% 28%) 81%,
|
119 |
+
hsl(320deg 88% 30%) 87%,
|
120 |
+
hsl(323deg 81% 32%) 94%,
|
121 |
+
hsl(326deg 75% 33%) 100%
|
122 |
+
);
|
123 |
+
border: none;
|
124 |
+
color: white;
|
125 |
+
padding: 10px 20px;
|
126 |
+
text-align: center;
|
127 |
+
text-decoration: none;
|
128 |
+
display: inline-block;
|
129 |
+
font-size: 16px;
|
130 |
+
margin-top: 10px;
|
131 |
+
cursor: pointer;
|
132 |
+
border-radius: 5px;
|
133 |
+
display: block; /* Change display property to block */
|
134 |
+
margin: 0 auto;
|
135 |
+
Width :200px;
|
136 |
+
}
|
137 |
+
|
138 |
+
/* Hover effect for the swap button */
|
139 |
+
button[type="button"]:hover {
|
140 |
+
background-color: #45a049;
|
141 |
+
}
|
142 |
+
h1 {
|
143 |
+
text-align: center;
|
144 |
+
margin-bottom: 20px;
|
145 |
+
font-family: 'Barlow Condensed';
|
146 |
+
color: pink;
|
147 |
+
font-size: 40px; /* Adjust the font size as needed */
|
148 |
+
}
|
149 |
+
|
150 |
+
h2 {
|
151 |
+
font-size: 24px; /* Adjust size as needed */
|
152 |
+
font-family: 'Barlow Condensed';
|
153 |
+
color: #FFFFFF; /* Text color */
|
154 |
+
|
155 |
+
margin-top: 20px; /* Top margin */
|
156 |
+
margin-bottom: 10px; /* Bottom margin */
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
#resultImage {
|
161 |
+
border: 2px solid blue;
|
162 |
+
width: 269px;
|
163 |
+
height: 300px;
|
164 |
+
display: flex;
|
165 |
+
flex-direction: column;
|
166 |
+
overflow-y: scroll;
|
167 |
+
margin: auto;
|
168 |
+
margin-top: 30px;
|
169 |
+
padding-bottom: 7px;
|
170 |
+
gap: 14px;
|
171 |
+
background: linear-gradient(black , black) padding-box,
|
172 |
+
linear-gradient(to right, red, blue) border-box;
|
173 |
+
border-radius: 20px;
|
174 |
+
border: 2.5px solid transparent;
|
175 |
+
}
|
176 |
+
|
177 |
+
#sourceImageContainer, #destinationImageContainer {
|
178 |
+
border: 2px solid blue;
|
179 |
+
width: 200px;
|
180 |
+
height: 200px;
|
181 |
+
display: flex;
|
182 |
+
flex-direction: column;
|
183 |
+
overflow-y: scroll;
|
184 |
+
margin: auto;
|
185 |
+
margin-top: 30px;
|
186 |
+
padding-bottom: 7px;
|
187 |
+
gap: 100px;
|
188 |
+
background: linear-gradient(black , black) padding-box,
|
189 |
+
linear-gradient(to right, red, blue) border-box;
|
190 |
+
border-radius: 20px;
|
191 |
+
border: 2.5px solid transparent;
|
192 |
+
}
|
193 |
+
|
194 |
+
#sourceImage, #destinationImage {
|
195 |
+
max-width: 100%;
|
196 |
+
height: auto;
|
197 |
+
display: block;
|
198 |
+
margin: auto;
|
199 |
+
}
|
200 |
+
|
201 |
+
#loadingSpinner {
|
202 |
+
border: 3px solid rgba(255, 255, 255, 0.3);
|
203 |
+
border-radius: 50%;
|
204 |
+
border-top: 5px solid #ffffff;
|
205 |
+
width: 20px;
|
206 |
+
height: 20px;
|
207 |
+
animation: spin 2s linear infinite;
|
208 |
+
position: relative;
|
209 |
+
top: 50%;
|
210 |
+
left: 50%;
|
211 |
+
transform: translate(-50%, -50%);
|
212 |
+
display: none; /* Initially hide the loading spinner */
|
213 |
+
}
|
214 |
+
|
215 |
+
@keyframes spin {
|
216 |
+
0% { transform: rotate(0deg); }
|
217 |
+
100% { transform: rotate(360deg); }
|
218 |
+
}
|
219 |
+
</style>
|
220 |
+
</head>
|
221 |
+
<body>
|
222 |
+
<h1>Aiconvert.online </h1>
|
223 |
+
<form id="uploadForm" action="/upload/" method="post" enctype="multipart/form-data">
|
224 |
+
<label for="sourceFile" class="uploadLabel">Choose image </label>
|
225 |
+
<input type="file" id="sourceFile" name="source_file" accept="image/*" required onchange="previewImage(event, 'sourceImage')"><br>
|
226 |
+
<div id="sourceImageContainer">
|
227 |
+
<img id="sourceImage">
|
228 |
+
</div><br>
|
229 |
+
<button type="button" onclick="uploadFile()">Generate </button> <!-- Changed to type="button" and added onclick handler -->
|
230 |
+
</form>
|
231 |
+
<div id="resultImage">
|
232 |
+
<div id="loadingSpinner" style="display: none;">
|
233 |
+
<!-- Replace this with your loading spinner HTML/CSS -->
|
234 |
+
</div>
|
235 |
+
<div id="resultContainer">
|
236 |
+
|
237 |
+
<script>
|
238 |
+
function previewImage(event, imageId) {
|
239 |
+
const fileInput = event.target;
|
240 |
+
const file = fileInput.files[0];
|
241 |
+
const reader = new FileReader();
|
242 |
+
|
243 |
+
reader.onload = function(e) {
|
244 |
+
const image = document.getElementById(imageId);
|
245 |
+
image.src = e.target.result;
|
246 |
+
}
|
247 |
+
|
248 |
+
reader.readAsDataURL(file);
|
249 |
+
}
|
250 |
+
|
251 |
+
async function uploadFile() {
|
252 |
+
const sourceFileInput = document.getElementById('sourceFile');
|
253 |
+
const resultContainer = document.getElementById('resultContainer');
|
254 |
+
|
255 |
+
|
256 |
+
|
257 |
+
// Check if both source and destination file inputs are empty
|
258 |
+
if (!sourceFileInput.files[0] ) {
|
259 |
+
// Update the result container with the error message
|
260 |
+
resultContainer.innerHTML = "<p>Please upload an image.</p>";
|
261 |
+
return;
|
262 |
+
}
|
263 |
+
|
264 |
+
// Clear the result container if both images are uploaded
|
265 |
+
resultContainer.innerHTML = "";
|
266 |
+
|
267 |
+
const formData = new FormData();
|
268 |
+
const fileInput = document.querySelector('input[type="file"]');
|
269 |
+
formData.append('file', fileInput.files[0]);
|
270 |
+
|
271 |
+
try {
|
272 |
+
// Display loading spinner
|
273 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
274 |
+
loadingSpinner.style.display = 'block';
|
275 |
+
|
276 |
+
const response = await fetch('/upload/', {
|
277 |
+
method: 'POST',
|
278 |
+
body: formData
|
279 |
+
});
|
280 |
+
if (response.ok) {
|
281 |
+
// If successful response, display the result image
|
282 |
+
const data = await response.json();
|
283 |
+
const sketchImage = document.createElement('img');
|
284 |
+
sketchImage.src = data.sketch_image_base64;
|
285 |
+
} else {
|
286 |
+
// If server error, display the error message
|
287 |
+
const errorMessage = await response.text();
|
288 |
+
resultContainer.innerHTML = `<p>Oops! Something went wrong. Please try again later. </p>`;
|
289 |
+
}
|
290 |
+
// Hide loading spinner after result (or error message) is displayed
|
291 |
+
loadingSpinner.style.display = 'none';
|
292 |
+
} catch (error) {
|
293 |
+
console.error('Error swapping faces:', error);
|
294 |
+
// Hide loading spinner if there's an error
|
295 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
296 |
+
loadingSpinner.style.display = 'none';
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
|
303 |
+
</script>
|
304 |
+
</body>
|
305 |
+
</html>
|