Spaces:
Paused
Paused
Update static/index.html
Browse files- static/index.html +11 -10
static/index.html
CHANGED
|
@@ -265,6 +265,7 @@ h1 {
|
|
| 265 |
}
|
| 266 |
|
| 267 |
|
|
|
|
| 268 |
async function swapFaces() {
|
| 269 |
const form = document.getElementById('swapForm');
|
| 270 |
const formData = new FormData(form);
|
|
@@ -274,7 +275,7 @@ h1 {
|
|
| 274 |
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 275 |
loadingSpinner.style.display = 'block';
|
| 276 |
|
| 277 |
-
// Remove previous result image and
|
| 278 |
const resultContainer = document.getElementById('resultContainer');
|
| 279 |
resultContainer.innerHTML = '';
|
| 280 |
|
|
@@ -283,20 +284,17 @@ h1 {
|
|
| 283 |
body: formData
|
| 284 |
});
|
| 285 |
|
| 286 |
-
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|
| 300 |
loadingSpinner.style.display = 'none';
|
| 301 |
} catch (error) {
|
| 302 |
console.error('Error swapping faces:', error);
|
|
@@ -307,6 +305,9 @@ h1 {
|
|
| 307 |
}
|
| 308 |
|
| 309 |
|
|
|
|
|
|
|
|
|
|
| 310 |
</script>
|
| 311 |
</body>
|
| 312 |
</html>
|
|
|
|
| 265 |
}
|
| 266 |
|
| 267 |
|
| 268 |
+
|
| 269 |
async function swapFaces() {
|
| 270 |
const form = document.getElementById('swapForm');
|
| 271 |
const formData = new FormData(form);
|
|
|
|
| 275 |
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 276 |
loadingSpinner.style.display = 'block';
|
| 277 |
|
| 278 |
+
// Remove previous result image and message
|
| 279 |
const resultContainer = document.getElementById('resultContainer');
|
| 280 |
resultContainer.innerHTML = '';
|
| 281 |
|
|
|
|
| 284 |
body: formData
|
| 285 |
});
|
| 286 |
|
| 287 |
+
if (response.status === 400) {
|
| 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
|
| 298 |
loadingSpinner.style.display = 'none';
|
| 299 |
} catch (error) {
|
| 300 |
console.error('Error swapping faces:', error);
|
|
|
|
| 305 |
}
|
| 306 |
|
| 307 |
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
|
| 311 |
</script>
|
| 312 |
</body>
|
| 313 |
</html>
|