Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,22 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
import pathlib
|
3 |
from deepface import DeepFace
|
|
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
#from datasets import load_dataset
|
11 |
-
#db_path= load_dataset("imagefolder", data_files=db_path)
|
12 |
|
13 |
|
14 |
-
|
15 |
-
def get_deepface(image):
|
16 |
-
df = DeepFace.find(img_path=image, db_path=db_path)
|
17 |
-
d = DeepFace.analyze(img_path=image)
|
18 |
-
#new_list = zip(d.keys(), d.values())
|
19 |
-
#new_list = list(new_list)
|
20 |
-
return d
|
21 |
-
|
22 |
-
description = "Deepface is a lightweight face recognition and facial attribute analysis (age, gender, emotion and race) framework for python. It is a hybrid face recognition framework wrapping state-of-the-art models: VGG-Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib."
|
23 |
|
24 |
-
facial_attribute_demo = gr.Interface(
|
25 |
-
fn=get_deepface,
|
26 |
-
inputs="image",
|
27 |
-
outputs=['text'],
|
28 |
-
title="face recognition and facial attribute analysis",
|
29 |
-
description=description,
|
30 |
-
enable_queue=True,
|
31 |
-
examples=[["10Jan_1.jpeg"]],
|
32 |
-
cache_examples=False)
|
33 |
|
34 |
facial_attribute_demo.launch()
|
|
|
1 |
+
#ALL as a whole
|
2 |
+
import os
|
3 |
import gradio as gr
|
|
|
4 |
from deepface import DeepFace
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
|
7 |
+
def get_deepface_verify(img1_detect, img2_detect ):
|
8 |
+
img1_detect= DeepFace.detectFace(img1_path)
|
9 |
+
img2_detect= DeepFace.detectFace(img2_path)
|
10 |
+
model_name = 'ArcFace' #VGG-Face, Facenet, OpenFace, DeepFace, DeepID, Dlib, ArcFace or Ensemble
|
11 |
+
result = DeepFace.verify(img1_path=img1_path,img2_path=img2_path,model_name = model_name)
|
12 |
+
return result
|
13 |
|
14 |
+
title = "DeepFace"
|
15 |
+
description = "Deepface is a lightweight face recognition and facial attribute analysis (age, gender, emotion and race) framework for python. It is a hybrid face recognition framework wrapping state-of-the-art models: VGG-Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib."
|
16 |
+
examples=[["10Jan_1.jpeg"],["10Jan_2.jpeg"]]
|
|
|
|
|
17 |
|
18 |
|
19 |
+
facial_attribute_demo = gr.Interface(get_deepface_verify,["image","image", 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
facial_attribute_demo.launch()
|