spideyhead commited on
Commit
8627c60
·
verified ·
1 Parent(s): a4484b5

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -61,11 +61,11 @@ def extract_faces_from_video(video_path, max_frames=8):
61
  if boxes is not None and len(boxes) > 0:
62
  box = boxes[0]
63
 
64
- # Add 30% padding around the face. Deepfake models need to see the jawline and background boundaries!
65
  w = box[2] - box[0]
66
  h = box[3] - box[1]
67
- pad_w = int(w * 0.3)
68
- pad_h = int(h * 0.3)
69
 
70
  # Ensure box coordinates are within image bounds with padding
71
  x1 = max(0, int(box[0]) - pad_w)
@@ -128,7 +128,7 @@ async def analyze_video(file: UploadFile = File(...)):
128
  # Get average probability for 'Fake' class across the worst frames
129
  avg_fake_prob = top_k_probs.mean().item()
130
 
131
- is_fake = avg_fake_prob > 0.5
132
 
133
  # Calculate confidence score based on the chosen class
134
  if is_fake:
 
61
  if boxes is not None and len(boxes) > 0:
62
  box = boxes[0]
63
 
64
+ # Add 10% padding around the face. Reduced from 30% to prevent background noise interference.
65
  w = box[2] - box[0]
66
  h = box[3] - box[1]
67
+ pad_w = int(w * 0.1)
68
+ pad_h = int(h * 0.1)
69
 
70
  # Ensure box coordinates are within image bounds with padding
71
  x1 = max(0, int(box[0]) - pad_w)
 
128
  # Get average probability for 'Fake' class across the worst frames
129
  avg_fake_prob = top_k_probs.mean().item()
130
 
131
+ is_fake = avg_fake_prob > 0.75
132
 
133
  # Calculate confidence score based on the chosen class
134
  if is_fake: