Spaces:
Sleeping
Sleeping
Update prediction.py
Browse files- prediction.py +7 -9
prediction.py
CHANGED
|
@@ -332,19 +332,17 @@ class Prediction:
|
|
| 332 |
)
|
| 333 |
prediction_string = f"{prediction} {confidence_deepfake_real:.2f}% Confidence"
|
| 334 |
|
| 335 |
-
# Create detailed classification results as
|
| 336 |
if prediction == "Deepfake":
|
| 337 |
# For deepfakes, show probabilities for each deepfake type
|
| 338 |
-
classification_details =
|
| 339 |
-
|
| 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 |
-
|
| 347 |
-
|
| 348 |
|
| 349 |
# Backpropagate for Grad-CAM
|
| 350 |
self.model.zero_grad()
|
|
|
|
| 332 |
)
|
| 333 |
prediction_string = f"{prediction} {confidence_deepfake_real:.2f}% Confidence"
|
| 334 |
|
| 335 |
+
# Create detailed classification results as a dictionary
|
| 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 |
else:
|
| 342 |
# For real videos, just show real confidence
|
| 343 |
+
classification_details = {
|
| 344 |
+
"Real": float(class_probs[0])
|
| 345 |
+
}
|
| 346 |
|
| 347 |
# Backpropagate for Grad-CAM
|
| 348 |
self.model.zero_grad()
|