mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 11:35:21 +00:00
unit tests for find and ensemble
This commit is contained in:
parent
2f9815a1fc
commit
f95f5acbe8
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,4 +13,5 @@ deepface/__pycache__/*
|
||||
deepface/commons/__pycache__/*
|
||||
deepface/basemodels/__pycache__/*
|
||||
deepface/extendedmodels/__pycache__/*
|
||||
deepface/subsidiarymodels/__pycache__/*
|
||||
deepface/subsidiarymodels/__pycache__/*
|
||||
deepface/tests/dataset/*.pkl
|
@ -98,6 +98,15 @@ result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face", distan
|
||||
result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face", distance_metric = "euclidean_l2")
|
||||
```
|
||||
|
||||
** Ensemble learning for face recognition ** - Demo
|
||||
|
||||
A face recognition task can be handled by several models and similarity metrics. There is no either absolute better model or metric. However, we can combine the precictions of all of those models and metrics to improve the accuracy of a face recognition task. This is called [ensemble learning](https://sefiks.com/2020/06/03/mastering-face-recognition-with-ensemble-learning/). This approach offers a huge improvement on accuracy, precision and recall but it runs much slower than single models. You might consider to apply ensemble learning if the accuracy is a more important KPI than running time in your case. Ensemble learning can be applied for both verification and finding functions in the deepface interface.
|
||||
|
||||
```python
|
||||
resp_obj = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "Ensemble")
|
||||
df = DeepFace.find(img_path = "img1.jpg", db_path = "my_db", model_name = "Ensemble")
|
||||
```
|
||||
|
||||
**Facial Attribute Analysis** - [`Demo`](https://youtu.be/GT2UeN85BdA)
|
||||
|
||||
Deepface also offers facial attribute analysis including [`age`](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [`gender`](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [`facial expression`](https://sefiks.com/2018/01/01/facial-expression-recognition-with-keras/) (including angry, fear, neutral, sad, disgust, happy and surprise)and [`race`](https://sefiks.com/2019/11/11/race-and-ethnicity-prediction-in-keras/) (including asian, white, middle eastern, indian, latino and black) predictions. Analysis function under the DeepFace interface is used to find demography of a face.
|
||||
|
@ -695,6 +695,7 @@ def find(img_path, db_path
|
||||
df = df[df.verified == True]
|
||||
df = df[df.score > 0.99] #confidence score
|
||||
df = df.sort_values(by = ["score"], ascending=False).reset_index(drop=True)
|
||||
df = df[['identity', 'verified', 'score']]
|
||||
|
||||
resp_obj.append(df)
|
||||
df = df_base.copy() #restore df for the next iteration
|
||||
|
BIN
tests/dataset/representations_ensemble.pkl
Normal file
BIN
tests/dataset/representations_ensemble.pkl
Normal file
Binary file not shown.
BIN
tests/dataset/representations_vgg_face.pkl
Normal file
BIN
tests/dataset/representations_vgg_face.pkl
Normal file
Binary file not shown.
@ -5,12 +5,23 @@ import os
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
||||
#-----------------------------------------
|
||||
|
||||
#TODO: add find function in unit tests
|
||||
|
||||
print("Bulk tests")
|
||||
|
||||
print("-----------------------------------------")
|
||||
|
||||
print("Large scale face recognition")
|
||||
|
||||
df = DeepFace.find(img_path = "dataset/img1.jpg", db_path = "dataset")
|
||||
print(df.head())
|
||||
|
||||
print("-----------------------------------------")
|
||||
|
||||
print("Ensemble for find function")
|
||||
df = DeepFace.find(img_path = "dataset/img1.jpg", db_path = "dataset", model_name = "Ensemble")
|
||||
print(df.head())
|
||||
|
||||
print("-----------------------------------------")
|
||||
|
||||
print("Bulk face recognition tests")
|
||||
|
||||
dataset = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user