Update app.py
Browse files
app.py
CHANGED
|
@@ -71,19 +71,23 @@ def analyze_video(video):
|
|
| 71 |
|
| 72 |
ai_scores = probs[:, ai_class_index].tolist()
|
| 73 |
|
| 74 |
-
# Verdict logic
|
| 75 |
-
ai_conf_threshold = 0.7
|
| 76 |
-
min_ai_frames = 3
|
| 77 |
avg_score = sum(ai_scores) / len(ai_scores)
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# Output results
|
| 88 |
results = []
|
| 89 |
for frame_idx, pred, ai_score in zip(frame_numbers, predictions, ai_scores):
|
|
|
|
| 71 |
|
| 72 |
ai_scores = probs[:, ai_class_index].tolist()
|
| 73 |
|
|
|
|
|
|
|
|
|
|
| 74 |
avg_score = sum(ai_scores) / len(ai_scores)
|
| 75 |
+
total_frames = len(ai_scores)
|
| 76 |
+
ai_frame_count = sum(1 for score in ai_scores if score >= 0.5) # Soft threshold for "suspicious" frame
|
| 77 |
+
ai_frame_ratio = ai_frame_count / total_frames
|
| 78 |
+
|
| 79 |
+
# Refined verdict based on AI frame ratio and confidence
|
| 80 |
+
if ai_frame_ratio < 0.25:
|
| 81 |
+
verdict = "β
Very likely real β no strong signs of AI generation."
|
| 82 |
+
elif 0.25 <= ai_frame_ratio < 0.5:
|
| 83 |
+
verdict = "β οΈ Mostly real β a few signs could raise suspicion."
|
| 84 |
+
elif ai_frame_ratio >= 0.5:
|
| 85 |
+
if avg_score >= 0.85:
|
| 86 |
+
verdict = "π¨ Definitely AI-generated β high confidence across many frames."
|
| 87 |
+
elif avg_score >= 0.75:
|
| 88 |
+
verdict = "β οΈ Likely AI-generated β multiple signs suggest manipulation."
|
| 89 |
+
else:
|
| 90 |
+
verdict = "π€ Unclear β the video shows mixed signals."
|
| 91 |
# Output results
|
| 92 |
results = []
|
| 93 |
for frame_idx, pred, ai_score in zip(frame_numbers, predictions, ai_scores):
|