import gradio as gr from run import get_model, detect_video model = get_model() def greet(video): print(video, type(video)) generated_pred = detect_video(video_path=video, model=model) # generated_pred = 0.93443 # context_pred = 0.9164814352989197 # context_pred = 0.3335219025611877 context_pred = 0.7490718364715576 generated_output = f"Fake: {generated_pred*100:.2f}%" if generated_pred > 0.5 else f"Real: {(1-generated_pred)*100:.2f}%" context_output = f"Fake: {context_pred*100:.2f}%" if context_pred > 0.5 else f"Real: {(1-context_pred)*100:.2f}%" print(generated_output, '\n', context_output) return generated_output, context_output with gr.Blocks() as demo: gr.Markdown("# Fake Video Detector") with gr.Tabs(): with gr.TabItem("Video Detect"): with gr.Column(): video_input = gr.Video(height=330) video_button = gr.Button("detect") detect_output = gr.Textbox(label="AI detect result") context_output = gr.Textbox(label="Context detect result") video_button.click(greet, inputs=video_input, outputs=[detect_output, context_output]) demo.launch()