| import gradio as gr |
| import os |
|
|
| |
| 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 |
| from fake_image import predict_image as image_pipeline |
|
|
| |
| with gr.Blocks(theme=gr.themes.Soft(), title="Deepfake Detector") as demo: |
| gr.Markdown("<h1 style='text-align: center;'>π‘οΈ Deepfake Detection System</h1>") |
| gr.Markdown("<p style='text-align: center;'>Comprehensive analysis across Text, Audio, Video, and Lip-Sync domains.</p>") |
| |
| with gr.Tabs(): |
| |
| |
| with gr.TabItem("π° Fake Text/News"): |
| gr.Markdown("### π§ Text Claim Analysis") |
| 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]) |
|
|
| |
| with gr.TabItem("ποΈ Audio Forensics"): |
| gr.Markdown("### π Audio Texture & Splice Analysis") |
| with gr.Row(): |
| aud_in = gr.Audio(type="filepath", label="Upload audio file") |
| with gr.Row(): |
| aud_btn = gr.Button("π Run", variant="primary") |
| with gr.Row(): |
| with gr.Column(): |
| aud_v_out = gr.Textbox(label="Final Remarks") |
| aud_e_out = gr.Textbox(label="Categorized Evidence (Metrics)") |
| with gr.Column(): |
| aud_r_out = gr.Textbox(label="Reasoning", lines=4) |
| |
| aud_btn.click(analyze_voice_forensics, inputs=[aud_in], outputs=[aud_v_out, aud_e_out, aud_r_out]) |
|
|
| |
| with gr.TabItem("π₯ Video Forensics"): |
| gr.Markdown("### π Video analysis") |
| 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="Reasoning", lines=5) |
| vid_hidden = gr.Textbox(visible=False) |
| |
| vid_btn.click(video_pipeline, inputs=[vid_in], outputs=[vid_img_out, vid_txt_out, vid_reason_out, vid_hidden]) |
|
|
| |
| with gr.TabItem("π Multi-Modal Analysis (Lip-Sync)"): |
| gr.Markdown("### βοΈ Multi-Modal Analysis: Video + Audio") |
| with gr.Row(): |
| master_vid_in = gr.Video(label="Upload Video") |
| master_btn = gr.Button("π Run 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=" Report") |
| with gr.Row(): |
| master_reason_out = gr.Textbox(label=" Reasoning", lines=3) |
| |
| master_btn.click(lipsync_pipeline, inputs=[master_vid_in], outputs=[master_img_out, master_txt_out, master_reason_out]) |
|
|
| |
| with gr.Tab("πΌοΈ Image Analysis"): |
| gr.Markdown(" Deepfake Images Detector") |
| with gr.Row(): |
| with gr.Column(): |
| img_in = gr.Image(type="pil", label=" Upload Image") |
| img_btn = gr.Button("Analyze Image", variant="primary") |
| with gr.Column(): |
| img_out = gr.Label(num_top_classes=2, label="Detection Result") |
| |
| img_btn.click(fn=image_pipeline, inputs=[img_in], outputs=[img_out]) |
|
|
| |
| if __name__ == "__main__": |
| demo.launch(share=True, debug=True) |