|
import gradio as gr |
|
from detector.face import verify_faces |
|
|
|
|
|
def compare_face(image1, image2): |
|
result = verify_faces(image1, image2) |
|
if "error" in result: |
|
return f"β Error: {result['error']}" |
|
|
|
if result["verified"]: |
|
return f"β
Match! Distance: {result['distance']:.4f} (Threshold: {result['threshold']})" |
|
else: |
|
return f"β No Match. Distance: {result['distance']:.4f} (Threshold: {result['threshold']})" |
|
|
|
|
|
with gr.Blocks(title="Deepfake Watchdog") as app: |
|
gr.Markdown( |
|
"# π€ Gradio & MCP Tool\n ## This is an MCP-compatible Gradio app that verifies if two face images belong to the same person using DeepFace." |
|
) |
|
|
|
with gr.Row(): |
|
image1 = gr.Image(label="Upload your face", type="filepath") |
|
image2 = gr.Image(label="Upload your face", type="filepath") |
|
|
|
check_button = gr.Button("Compare Faces") |
|
|
|
output_text = gr.Textbox(label="Status") |
|
|
|
check_button.click(compare_face, inputs=[image1, image2], outputs=[output_text]) |
|
|
|
|
|
app.launch(mcp_server=True) |
|
|