Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -76,25 +76,36 @@ def analyze_video(video_file):
|
|
76 |
return {"error": "Server misconfiguration. Access key not set."}
|
77 |
|
78 |
try:
|
79 |
-
truncated_video = truncate_video(video_file) # Truncate the video for faster analysis
|
80 |
results = analyzer.analyze_media(truncated_video)
|
81 |
|
82 |
-
#
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
88 |
else:
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
#
|
92 |
output = {
|
93 |
-
"message":
|
94 |
-
f"{len(results['video_analysis']['frame_results'])} frames were analyzed in total.",
|
95 |
"details": {
|
96 |
-
"video_probability":
|
97 |
-
"combined_assessment":
|
98 |
}
|
99 |
}
|
100 |
return output
|
@@ -105,6 +116,7 @@ def analyze_video(video_file):
|
|
105 |
|
106 |
|
107 |
|
|
|
108 |
interface = gr.Interface(
|
109 |
fn=analyze_video,
|
110 |
inputs=gr.Video(label="Upload Video"),
|
|
|
76 |
return {"error": "Server misconfiguration. Access key not set."}
|
77 |
|
78 |
try:
|
79 |
+
truncated_video = truncate_video(video_file) # Truncate the video for faster analysis
|
80 |
results = analyzer.analyze_media(truncated_video)
|
81 |
|
82 |
+
# Extract frame count and video probability
|
83 |
+
frame_count = len(results['video_analysis']['frame_results'])
|
84 |
+
video_probability = results['video_analysis']['probability']
|
85 |
+
combined_assessment = results.get('combined_assessment', "Inconclusive")
|
86 |
+
|
87 |
+
# Reapply combined_results logic for front-end clarity
|
88 |
+
if frame_count < 300:
|
89 |
+
assessment = "Inconclusive due to lack of sufficient frames"
|
90 |
+
elif frame_count < 500:
|
91 |
+
threshold = 0.4
|
92 |
+
assessment = "Deepfake" if video_probability >= threshold else "Genuine"
|
93 |
else:
|
94 |
+
threshold = 0.5
|
95 |
+
assessment = "Deepfake" if video_probability >= threshold else "Genuine"
|
96 |
+
|
97 |
+
# Construct output message
|
98 |
+
message = (
|
99 |
+
f"According to our analysis, the video you uploaded appears to be {assessment}. "
|
100 |
+
f"{frame_count} frames were analyzed in total."
|
101 |
+
)
|
102 |
|
103 |
+
# Return the final output
|
104 |
output = {
|
105 |
+
"message": message,
|
|
|
106 |
"details": {
|
107 |
+
"video_probability": video_probability,
|
108 |
+
"combined_assessment": assessment # Final assessment based on reapplied logic
|
109 |
}
|
110 |
}
|
111 |
return output
|
|
|
116 |
|
117 |
|
118 |
|
119 |
+
|
120 |
interface = gr.Interface(
|
121 |
fn=analyze_video,
|
122 |
inputs=gr.Video(label="Upload Video"),
|