Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -67,7 +67,6 @@ backend = import_backend_script("app.py") # Import app.py from the cloned repos
|
|
67 |
# Initialize the analyzer instance from the imported module
|
68 |
analyzer = backend.DeepfakeAnalyzer() # Use the imported module's class or function
|
69 |
|
70 |
-
# Define the Gradio function to analyze the video
|
71 |
# Define the Gradio function to analyze the video
|
72 |
def analyze_video(video_file):
|
73 |
# Truncate the video to 15 seconds
|
@@ -75,28 +74,33 @@ def analyze_video(video_file):
|
|
75 |
|
76 |
# Pass the truncated video to the analyzer
|
77 |
results = analyzer.analyze_media(truncated_video)
|
|
|
|
|
78 |
combined_probability = results['combined_assessment']
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
for frame_result in results['video_analysis']['frame_results']
|
95 |
-
]
|
96 |
-
}
|
97 |
-
}
|
98 |
-
return output
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
# Define the Gradio interface
|
102 |
interface = gr.Interface(
|
|
|
67 |
# Initialize the analyzer instance from the imported module
|
68 |
analyzer = backend.DeepfakeAnalyzer() # Use the imported module's class or function
|
69 |
|
|
|
70 |
# Define the Gradio function to analyze the video
|
71 |
def analyze_video(video_file):
|
72 |
# Truncate the video to 15 seconds
|
|
|
74 |
|
75 |
# Pass the truncated video to the analyzer
|
76 |
results = analyzer.analyze_media(truncated_video)
|
77 |
+
|
78 |
+
# Get the combined assessment probability
|
79 |
combined_probability = results['combined_assessment']
|
80 |
+
|
81 |
+
# Interpret the result as genuine or deepfake based on probability threshold
|
82 |
+
if combined_probability < 50:
|
83 |
+
analysis_result = "genuine/original"
|
84 |
+
else:
|
85 |
+
analysis_result = "a deepfake"
|
86 |
+
|
87 |
+
# Create a readable output message
|
88 |
+
output_text = (
|
89 |
+
f"According to our analysis, the video you uploaded appears to be {analysis_result} "
|
90 |
+
f"with a {combined_probability:.2f}% probability. "
|
91 |
+
f"{len(results['video_analysis']['frame_results'])} frames were analyzed in total."
|
92 |
+
)
|
93 |
+
|
94 |
+
return output_text
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
# Define the Gradio interface with a text output for readability
|
97 |
+
interface = gr.Interface(
|
98 |
+
fn=analyze_video,
|
99 |
+
inputs=gr.Video(label="Upload Video"),
|
100 |
+
outputs="text",
|
101 |
+
title="AllMark - Deepfake Analyzer",
|
102 |
+
description="Upload a video to analyze for deepfake content. Get an assessment of the likelihood that the video is genuine or a deepfake."
|
103 |
+
)
|
104 |
|
105 |
# Define the Gradio interface
|
106 |
interface = gr.Interface(
|