Spaces:
Paused
Paused
Update static/index.html
Browse files- static/index.html +34 -23
static/index.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
|
| 7 |
<style>
|
|
@@ -264,38 +264,49 @@ h1 {
|
|
| 264 |
reader.readAsDataURL(file);
|
| 265 |
}
|
| 266 |
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
|
|
|
| 270 |
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
| 284 |
const blob = await response.blob();
|
| 285 |
const imageUrl = URL.createObjectURL(blob);
|
| 286 |
|
| 287 |
// Display the result image
|
| 288 |
resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
|
| 289 |
-
|
| 290 |
-
//
|
| 291 |
-
|
| 292 |
-
|
| 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 |
</script>
|
| 300 |
</body>
|
| 301 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
+
|
| 5 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
|
| 6 |
<link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
|
| 7 |
<style>
|
|
|
|
| 264 |
reader.readAsDataURL(file);
|
| 265 |
}
|
| 266 |
|
| 267 |
+
|
| 268 |
+
async function swapFaces() {
|
| 269 |
+
const form = document.getElementById('swapForm');
|
| 270 |
+
const formData = new FormData(form);
|
| 271 |
|
| 272 |
+
try {
|
| 273 |
+
// Display loading spinner
|
| 274 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 275 |
+
loadingSpinner.style.display = 'block';
|
| 276 |
|
| 277 |
+
// Remove previous result image and error message
|
| 278 |
+
const resultContainer = document.getElementById('resultContainer');
|
| 279 |
+
resultContainer.innerHTML = '';
|
| 280 |
|
| 281 |
+
const response = await fetch('/swap_faces/', {
|
| 282 |
+
method: 'POST',
|
| 283 |
+
body: formData
|
| 284 |
+
});
|
| 285 |
+
|
| 286 |
+
// Check if response is ok
|
| 287 |
+
if (response.ok) {
|
| 288 |
const blob = await response.blob();
|
| 289 |
const imageUrl = URL.createObjectURL(blob);
|
| 290 |
|
| 291 |
// Display the result image
|
| 292 |
resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
|
| 293 |
+
} else {
|
| 294 |
+
// If response is not ok, display the error message
|
| 295 |
+
const errorMessage = await response.text();
|
| 296 |
+
resultContainer.innerText = errorMessage;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
}
|
| 298 |
+
|
| 299 |
+
// Hide loading spinner after result image or error message is displayed
|
| 300 |
+
loadingSpinner.style.display = 'none';
|
| 301 |
+
} catch (error) {
|
| 302 |
+
console.error('Error swapping faces:', error);
|
| 303 |
+
// Hide loading spinner if there's an error
|
| 304 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 305 |
+
loadingSpinner.style.display = 'none';
|
| 306 |
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
|
| 310 |
</script>
|
| 311 |
</body>
|
| 312 |
</html>
|