NeeravS commited on
Commit
4ea7444
·
verified ·
1 Parent(s): 589bf82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
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
- audio_analysis = results["audio_analysis"]
80
- video_probability = results['video_analysis']['probability']
81
- frame_count = len(results['video_analysis']['frame_results'])
82
-
83
- # Format the output for display
84
- output = {
85
- "Audio Analysis": audio_analysis,
86
- "Deepfake Probability (Combined Assessment)": f"{combined_probability:.2f}%",
87
- "Video Analysis": {
88
- "Deepfake Probability": f"{video_probability:.4f}",
89
- "Frames Analyzed": frame_count,
90
- "Frame Analysis Summary": [
91
- {
92
- "Probability": frame_result["probability"]
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(