Spaces:
Running
Running
Update prediction.py
Browse files- prediction.py +13 -12
prediction.py
CHANGED
|
@@ -332,18 +332,19 @@ class Prediction:
|
|
| 332 |
)
|
| 333 |
prediction_string = f"{prediction} {confidence_deepfake_real:.2f}% Confidence"
|
| 334 |
|
| 335 |
-
# Create detailed classification results
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
|
|
|
| 347 |
|
| 348 |
# Backpropagate for Grad-CAM
|
| 349 |
self.model.zero_grad()
|
|
|
|
| 332 |
)
|
| 333 |
prediction_string = f"{prediction} {confidence_deepfake_real:.2f}% Confidence"
|
| 334 |
|
| 335 |
+
# Create detailed classification results as list of (label, confidence) tuples
|
| 336 |
+
if prediction == "Deepfake":
|
| 337 |
+
# For deepfakes, show probabilities for each deepfake type
|
| 338 |
+
classification_details = [
|
| 339 |
+
(self.classes[i], float(class_probs[i])) for i in range(1, len(self.classes))
|
| 340 |
+
]
|
| 341 |
+
# Sort by confidence (highest first)
|
| 342 |
+
classification_details.sort(key=lambda x: x[1], reverse=True)
|
| 343 |
+
else:
|
| 344 |
+
# For real videos, just show real confidence
|
| 345 |
+
classification_details = [
|
| 346 |
+
("Real", float(class_probs[0]))
|
| 347 |
+
]
|
| 348 |
|
| 349 |
# Backpropagate for Grad-CAM
|
| 350 |
self.model.zero_grad()
|