File size: 4,101 Bytes
7f1f113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5275da3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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("<h1 style='text-align: center;'>πŸ›‘οΈ Unified AI Deepfake & Forensic Detection System</h1>")
    gr.Markdown("<p style='text-align: center;'>Comprehensive analysis across Text, Audio, Video, and Lip-Sync domains.</p>")
    
    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)