Ahsen Khaliq commited on
Commit
7cd7954
1 Parent(s): f954a49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -3,18 +3,14 @@ import gradio as gr
3
  from deepface import DeepFace
4
 
5
 
6
- def inference(image1,image2,model_name):
7
- result = DeepFace.verify(img1_path = image1, img2_path = image2,model_name=model_name)
8
- if result["verified"]:
9
- text = "same person"
10
- else:
11
- text = "different person"
12
  return result["verified"],result["distance"],result["max_threshold_to_verify"],result["model"],result["similarity_metric"]
13
 
14
- examples=[['mona.jpeg','mona.jpeg'],['mona.jpeg','pearl.jpeg']]
15
 
16
  title = "DeepFace"
17
  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."
18
  article = "<p style='text-align: center'><a href='https://github.com/serengil/deepface' target='_blank'>Github Repo</a></p>"
19
 
20
- gr.Interface(inference,["image","image",gr.inputs.Dropdown(choices=["VGG-Face", "Facenet", "OpenFace", "DeepFace"], type="value", default="VGG-Face", label="model name")],[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)
3
  from deepface import DeepFace
4
 
5
 
6
+ def inference(image1,image2,model_name,dist_met):
7
+ result = DeepFace.verify(img1_path = image1, img2_path = image2,model_name=model_name,distance_metric=dist_met)
 
 
 
 
8
  return result["verified"],result["distance"],result["max_threshold_to_verify"],result["model"],result["similarity_metric"]
9
 
10
+ examples=[['mona.jpeg','mona.jpeg','VGG-Face'],['mona.jpeg','pearl.jpeg','Facenet']]
11
 
12
  title = "DeepFace"
13
  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."
14
  article = "<p style='text-align: center'><a href='https://github.com/serengil/deepface' target='_blank'>Github Repo</a></p>"
15
 
16
+ 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)