Spaces:
Running
Running
Update index.html
Browse files- index.html +13 -29
index.html
CHANGED
|
@@ -37,39 +37,23 @@
|
|
| 37 |
resultDiv.textContent = 'Checking...';
|
| 38 |
|
| 39 |
try {
|
| 40 |
-
const
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
const base64Image = reader.result.split(',')[1]; // Get base64 image without metadata
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
'Content-Type': 'application/json'
|
| 51 |
-
},
|
| 52 |
-
body: JSON.stringify({
|
| 53 |
-
inputs: base64Image,
|
| 54 |
-
options: {
|
| 55 |
-
wait_for_model: true
|
| 56 |
-
}
|
| 57 |
-
})
|
| 58 |
-
});
|
| 59 |
-
|
| 60 |
-
const result = await response.json();
|
| 61 |
-
|
| 62 |
-
if (response.ok) {
|
| 63 |
-
const isAI = result[0]?.label === "AI-generated";
|
| 64 |
-
if (isAI) {
|
| 65 |
-
resultDiv.textContent = "This image is AI-generated.";
|
| 66 |
-
} else {
|
| 67 |
-
resultDiv.textContent = "This image is not AI-generated.";
|
| 68 |
-
}
|
| 69 |
} else {
|
| 70 |
-
resultDiv.textContent = "
|
| 71 |
}
|
| 72 |
-
}
|
|
|
|
|
|
|
| 73 |
} catch (error) {
|
| 74 |
resultDiv.textContent = "Error occurred while checking the image.";
|
| 75 |
}
|
|
|
|
| 37 |
resultDiv.textContent = 'Checking...';
|
| 38 |
|
| 39 |
try {
|
| 40 |
+
const response = await fetch('/check_image', {
|
| 41 |
+
method: 'POST',
|
| 42 |
+
body: formData
|
| 43 |
+
});
|
| 44 |
|
| 45 |
+
const result = await response.json();
|
|
|
|
| 46 |
|
| 47 |
+
if (response.ok) {
|
| 48 |
+
const isAI = result[0]?.label === "AI-generated";
|
| 49 |
+
if (isAI) {
|
| 50 |
+
resultDiv.textContent = "This image is AI-generated.";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
} else {
|
| 52 |
+
resultDiv.textContent = "This image is not AI-generated.";
|
| 53 |
}
|
| 54 |
+
} else {
|
| 55 |
+
resultDiv.textContent = "Error occurred: " + result.error;
|
| 56 |
+
}
|
| 57 |
} catch (error) {
|
| 58 |
resultDiv.textContent = "Error occurred while checking the image.";
|
| 59 |
}
|