NeeravS commited on
Commit
cb82c24
·
verified ·
1 Parent(s): 6430f00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py CHANGED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from app import DeepfakeAnalyzer # Import your backend code
3
+
4
+ # Initialize the analyzer instance
5
+ analyzer = DeepfakeAnalyzer()
6
+
7
+ # Define the Gradio function to analyze the video and return detailed results
8
+ def analyze_video(video_file):
9
+ # Run the analyzer on the video file
10
+ results = analyzer.analyze_media(video_file)
11
+
12
+ # Prepare detailed results
13
+ combined_probability = results['combined_assessment']
14
+ audio_analysis = results["audio_analysis"]
15
+ video_probability = results['video_analysis']['probability']
16
+ frame_count = len(results['video_analysis']['frame_results'])
17
+
18
+ # Format the output for display
19
+ output = {
20
+ "Audio Analysis": audio_analysis,
21
+ "Deepfake Probability (Combined Assessment)": f"{combined_probability:.2f}%",
22
+ "Video Analysis": {
23
+ "Deepfake Probability": f"{video_probability:.4f}",
24
+ "Frames Analyzed": frame_count,
25
+ "Frame Analysis Summary": [
26
+ {
27
+ "Frame Number": frame_result["frame_number"],
28
+ "Noise Level": frame_result["noise"],
29
+ "Edge Density": frame_result["edge_density"],
30
+ "Color Consistency": frame_result["color_consistency"],
31
+ "Temporal Difference": frame_result["temporal_difference"],
32
+ "Probability": frame_result["probability"]
33
+ }
34
+ for frame_result in results['video_analysis']['frame_results']
35
+ ]
36
+ }
37
+ }
38
+ return output
39
+
40
+ # Define the Gradio interface
41
+ interface = gr.Interface(
42
+ fn=analyze_video,
43
+ inputs=gr.Video(label="Upload Video"),
44
+ outputs="json",
45
+ title="Deepfake Analyzer",
46
+ description="Upload a video to analyze for deepfake content. The analyzer provides audio and video analysis results."
47
+ )
48
+
49
+ # Launch Gradio app
50
+ if __name__ == "__main__":
51
+ interface.launch()