Spaces:
Paused
Paused
Update static/index.html
Browse files- static/index.html +8 -4
static/index.html
CHANGED
|
@@ -266,6 +266,7 @@ h1 {
|
|
| 266 |
|
| 267 |
|
| 268 |
|
|
|
|
| 269 |
async function swapFaces() {
|
| 270 |
const form = document.getElementById('swapForm');
|
| 271 |
const formData = new FormData(form);
|
|
@@ -284,14 +285,15 @@ h1 {
|
|
| 284 |
body: formData
|
| 285 |
});
|
| 286 |
|
| 287 |
-
if (response.
|
| 288 |
-
// If Bad Request (e.g., no faces detected), display error message
|
| 289 |
-
resultContainer.innerHTML = '<p>No faces detected in the uploaded image.</p>';
|
| 290 |
-
} else {
|
| 291 |
// If successful response, display the result image
|
| 292 |
const blob = await response.blob();
|
| 293 |
const imageUrl = URL.createObjectURL(blob);
|
| 294 |
resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
}
|
| 296 |
|
| 297 |
// Hide loading spinner after result (or error message) is displayed
|
|
@@ -305,6 +307,8 @@ h1 {
|
|
| 305 |
}
|
| 306 |
|
| 307 |
|
|
|
|
|
|
|
| 308 |
|
| 309 |
|
| 310 |
|
|
|
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
+
|
| 270 |
async function swapFaces() {
|
| 271 |
const form = document.getElementById('swapForm');
|
| 272 |
const formData = new FormData(form);
|
|
|
|
| 285 |
body: formData
|
| 286 |
});
|
| 287 |
|
| 288 |
+
if (response.ok) {
|
|
|
|
|
|
|
|
|
|
| 289 |
// If successful response, display the result image
|
| 290 |
const blob = await response.blob();
|
| 291 |
const imageUrl = URL.createObjectURL(blob);
|
| 292 |
resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
|
| 293 |
+
} else {
|
| 294 |
+
// If server error, display the error message
|
| 295 |
+
const errorMessage = await response.text();
|
| 296 |
+
resultContainer.innerHTML = `<p>Error: ${errorMessage}</p>`;
|
| 297 |
}
|
| 298 |
|
| 299 |
// Hide loading spinner after result (or error message) is displayed
|
|
|
|
| 307 |
}
|
| 308 |
|
| 309 |
|
| 310 |
+
|
| 311 |
+
|
| 312 |
|
| 313 |
|
| 314 |
|