import gradio as gr # --- 1. IMPORT FUNCTIONS FROM YOUR CLEANED FILES --- from fake_text import hybrid_analysis from fake_audio import analyze_voice_forensics from fake_video import analyze_video as video_pipeline from final_lipsync import master_pipeline as lipsync_pipeline # --- 2. BUILD THE UNIFIED DASHBOARD --- with gr.Blocks(theme=gr.themes.Soft(), title="Unified Deepfake Detector") as demo: gr.Markdown("

🛡️ Unified AI Deepfake & Forensic Detection System

") gr.Markdown("

Comprehensive analysis across Text, Audio, Video, and Lip-Sync domains.

") with gr.Tabs(): # --- TAB 1: FAKE NEWS (TEXT) --- with gr.TabItem("📰 Fake Text/News"): gr.Markdown("### 🧠 Text Claim Analysis (Hybrid DeBERTa + Groq)") with gr.Row(): text_in = gr.Textbox(label="Enter News Claim", placeholder="e.g., The Eiffel Tower was sold today...") with gr.Row(): text_btn = gr.Button("🔍 Analyze Claim", variant="primary") with gr.Row(): text_out = gr.HTML(label="Verdict & Reasoning") text_btn.click(hybrid_analysis, inputs=[text_in], outputs=[text_out]) # --- TAB 2: FAKE AUDIO --- with gr.TabItem("🎙️ Audio Forensics"): gr.Markdown("### 🔊 Audio DNA, Texture & Splice Analysis") with gr.Row(): aud_in = gr.Audio(type="filepath", label="Upload Forensic Sample") with gr.Row(): aud_btn = gr.Button("🔍 Run Fuzzy Audit", variant="primary") with gr.Row(): with gr.Column(): aud_v_out = gr.Textbox(label="Final Verdict") aud_e_out = gr.Textbox(label="Categorized Evidence (Metrics)") with gr.Column(): aud_r_out = gr.Textbox(label="Forensic Reasoning (Claude/Groq)", lines=4) aud_btn.click(analyze_voice_forensics, inputs=[aud_in], outputs=[aud_v_out, aud_e_out, aud_r_out]) # --- TAB 3: FAKE VIDEO --- with gr.TabItem("🎥 Video Forensics"): gr.Markdown("### 🏃 Video Motion (VideoMAE) & Semantic Analysis (ViT)") with gr.Row(): vid_in = gr.Video(label="Upload Video for Analysis") vid_btn = gr.Button("🔍 Analyze Video", variant="primary") with gr.Row(): with gr.Column(): vid_img_out = gr.Image(label="Suspicious Keyframe", type="pil") with gr.Column(): vid_txt_out = gr.Markdown() with gr.Row(): vid_reason_out = gr.Textbox(label="Judge's Evidence", lines=5) vid_hidden = gr.Textbox(visible=False) # Hidden output from your logic vid_btn.click(video_pipeline, inputs=[vid_in], outputs=[vid_img_out, vid_txt_out, vid_reason_out, vid_hidden]) # --- TAB 4: MASTER PIPELINE (LIP-SYNC) --- with gr.TabItem("👄 Master Pipeline (Lip-Sync)"): gr.Markdown("### ⚖️ Multi-Modal Analysis: Video + Audio + LSE-Net Binding") with gr.Row(): master_vid_in = gr.Video(label="Upload Investigation Video (MP4)") master_btn = gr.Button("🔍 Run Master Analysis", variant="primary") with gr.Row(): with gr.Column(): master_img_out = gr.Image(label="Keyframe Analysis") with gr.Column(): master_txt_out = gr.Markdown(label="Master Report") with gr.Row(): master_reason_out = gr.Textbox(label="Judge Reasoning Log", lines=3) master_btn.click(lipsync_pipeline, inputs=[master_vid_in], outputs=[master_img_out, master_txt_out, master_reason_out]) # --- 3. LAUNCH THE APP --- if __name__ == "__main__": # share=True ensures you get a public link to test it on your tablet or share it! demo.launch(share=True, debug=True)