Spaces:
Sleeping
Sleeping
AMontiB
commited on
Commit
·
a482ad9
1
Parent(s):
ebb6a24
final update
Browse files
app.py
CHANGED
|
@@ -72,12 +72,18 @@ def predict(image_path, detector_name):
|
|
| 72 |
prediction = result.get('prediction', 'Unknown')
|
| 73 |
confidence = result.get('confidence', 0.0)
|
| 74 |
elapsed_time = result.get('elapsed_time', 0.0)
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return json.dumps(output, indent=2)
|
| 82 |
else:
|
| 83 |
return json.dumps({"error": "No result file generated. Check console logs for details."}, indent=2)
|
|
@@ -109,7 +115,7 @@ with demo:
|
|
| 109 |
|
| 110 |
### Understanding the Results
|
| 111 |
* **Prediction**: Tells if an image is **Real** or **Fake**.
|
| 112 |
-
* **Confidence
|
| 113 |
* **Elapsed Time**: The time the model needed to make the prediction (excluding preprocessing or model building).
|
| 114 |
""")
|
| 115 |
|
|
|
|
| 72 |
prediction = result.get('prediction', 'Unknown')
|
| 73 |
confidence = result.get('confidence', 0.0)
|
| 74 |
elapsed_time = result.get('elapsed_time', 0.0)
|
| 75 |
+
if prediction == 'fake':
|
| 76 |
+
output = {
|
| 77 |
+
"Prediction": prediction,
|
| 78 |
+
"Confidence": f"{confidence:.4f}",
|
| 79 |
+
"Elapsed Time": f"{elapsed_time:.3f}s"
|
| 80 |
+
}
|
| 81 |
+
else:
|
| 82 |
+
output = {
|
| 83 |
+
"Prediction": prediction,
|
| 84 |
+
"Confidence": f"{1-confidence:.4f}",
|
| 85 |
+
"Elapsed Time": f"{elapsed_time:.3f}s"
|
| 86 |
+
}
|
| 87 |
return json.dumps(output, indent=2)
|
| 88 |
else:
|
| 89 |
return json.dumps({"error": "No result file generated. Check console logs for details."}, indent=2)
|
|
|
|
| 115 |
|
| 116 |
### Understanding the Results
|
| 117 |
* **Prediction**: Tells if an image is **Real** or **Fake**.
|
| 118 |
+
* **Confidence**: The confidence with which the model determines if the image is real orfake.
|
| 119 |
* **Elapsed Time**: The time the model needed to make the prediction (excluding preprocessing or model building).
|
| 120 |
""")
|
| 121 |
|