SanskarModi commited on
Commit
0ef32f9
·
verified ·
1 Parent(s): c0beb72

Update prediction.py

Browse files
Files changed (1) hide show
  1. 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
- classification_details = (
337
- {
338
- "Deepfake type": predicted_class,
339
- "confidence(%)": f"{confidence_class:.2f}",
340
- }
341
- if prediction == "Deepfake"
342
- else {
343
- "Deepfake type": "None (Real video)",
344
- "confidence(%)": f"{confidence_class:.2f}",
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()