Spaces:
Runtime error
Runtime error
import os | |
import gradio as gr | |
# Clone the GitHub repository containing app.py if not already cloned | |
REPO_URL = "https://github.com/NeeravSood/AllMark-MVP" # Replace with your GitHub repo URL | |
if not os.path.exists("AllMark-MVP"): # Replace with your repo's folder name | |
os.system(f"git clone {REPO_URL}") | |
# Import the backend code after cloning the repo | |
from repository_name.app import DeepfakeAnalyzer # Adjust based on your repo and file structure | |
# Initialize the analyzer instance | |
analyzer = DeepfakeAnalyzer() | |
# Define the function for Gradio to call | |
def analyze_video(video_file): | |
results = analyzer.analyze_media(video_file) | |
combined_probability = results['combined_assessment'] | |
audio_analysis = results["audio_analysis"] | |
video_probability = results['video_analysis']['probability'] | |
frame_count = len(results['video_analysis']['frame_results']) | |
# Format the output for display | |
output = { | |
"Audio Analysis": audio_analysis, | |
"Deepfake Probability (Combined Assessment)": f"{combined_probability:.2f}%", | |
"Video Analysis": { | |
"Deepfake Probability": f"{video_probability:.4f}", | |
"Frames Analyzed": frame_count, | |
"Frame Analysis Summary": [ | |
{ | |
"Frame Number": frame_result["frame_number"], | |
"Noise Level": frame_result["noise"], | |
"Edge Density": frame_result["edge_density"], | |
"Color Consistency": frame_result["color_consistency"], | |
"Temporal Difference": frame_result["temporal_difference"], | |
"Probability": frame_result["probability"] | |
} | |
for frame_result in results['video_analysis']['frame_results'] | |
] | |
} | |
} | |
return output | |
# Define the Gradio interface | |
interface = gr.Interface( | |
fn=analyze_video, | |
inputs=gr.Video(label="Upload Video"), | |
outputs="json", | |
title="Deepfake Analyzer", | |
description="Upload a video to analyze for deepfake content." | |
) | |
# Launch Gradio app | |
if __name__ == "__main__": | |
interface.launch() | |