deepface / app.py
Ahsen Khaliq
Update app.py 07ddf7c
import os
import gradio as gr
from deepface import DeepFace
def inference(image1,image2,model_name,dist_met):
result = DeepFace.verify(img1_path = image1, img2_path = image2,model_name=model_name,distance_metric=dist_met)
return result["verified"],result["distance"],result["max_threshold_to_verify"],result["model"],result["similarity_metric"]
examples=[['mona.jpeg','mona.jpeg','VGG-Face','cosine'],['mona.jpeg','pearl.jpeg','Facenet','euclidean']]
title = "DeepFace"
description = "Gradio demo for DeepFace for face verification: verifies face pairs as same person or different persons. To use it, simply upload your images, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://github.com/serengil/deepface' target='_blank'>Github Repo</a></p>"
gr.Interface(inference,["image","image",gr.inputs.Dropdown(choices=["VGG-Face", "Facenet", "OpenFace", "DeepFace"], type="value", default="VGG-Face", label="model name"),gr.inputs.Radio(choices=["cosine", "euclidean", "euclidean_l2"], type="value", default="cosine", label="distance metric")],[gr.outputs.Label(label="same person"),gr.outputs.Label(label="distance"),gr.outputs.Label(label="max threshold to verify"),gr.outputs.Label(label="model"),gr.outputs.Label(label="similarity metric")],enable_queue=True,examples=examples, title=title,description=description,article=article,theme="darkdefault").launch(debug=True)