Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -69,29 +69,31 @@ analyzer = backend.DeepfakeAnalyzer() # Use the imported module's class or func
|
|
69 |
|
70 |
# Define the Gradio function to analyze the video
|
71 |
def analyze_video(video_file):
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
|
96 |
# Define the Gradio interface with a text output for readability
|
97 |
interface = gr.Interface(
|
|
|
69 |
|
70 |
# Define the Gradio function to analyze the video
|
71 |
def analyze_video(video_file):
|
72 |
+
try:
|
73 |
+
# Truncate the video to 15 seconds
|
74 |
+
truncated_video = truncate_video(video_file)
|
75 |
+
|
76 |
+
# Pass the truncated video to the analyzer
|
77 |
+
results = analyzer.analyze_media(truncated_video)
|
78 |
+
|
79 |
+
# Check combined probability to interpret the result
|
80 |
+
combined_probability = results.get('combined_assessment', 0)
|
81 |
+
analysis_result = "genuine/original" if combined_probability < 50 else "a deepfake"
|
82 |
+
|
83 |
+
# Construct the output message
|
84 |
+
output_text = (
|
85 |
+
f"According to our analysis, the video you uploaded appears to be {analysis_result} "
|
86 |
+
f"with a {combined_probability:.2f}% probability. "
|
87 |
+
f"{len(results['video_analysis']['frame_results'])} frames were analyzed in total."
|
88 |
+
)
|
89 |
+
|
90 |
+
return output_text
|
91 |
+
|
92 |
+
except Exception as e:
|
93 |
+
# Log the error and return a user-friendly message
|
94 |
+
logging.error(f"Error during analysis: {e}")
|
95 |
+
return "An error occurred during video analysis. Please check your input and try again."
|
96 |
+
|
97 |
|
98 |
# Define the Gradio interface with a text output for readability
|
99 |
interface = gr.Interface(
|