mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
testing images
This commit is contained in:
parent
b05434f82a
commit
4fb23655c9
46
README.md
46
README.md
@ -13,6 +13,16 @@ from deepface import DeepFace
|
|||||||
result = DeepFace.verify("img1.jpg", "img2.jpg")
|
result = DeepFace.verify("img1.jpg", "img2.jpg")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/tests/dataset/test-case-1.jpg"></p>
|
||||||
|
|
||||||
|
```
|
||||||
|
Model: VGG-Face
|
||||||
|
Similarity metric: Cosine
|
||||||
|
Found Distance: 0.25638097524642944
|
||||||
|
Max Threshold to Verify: 0.40
|
||||||
|
Result: They are same
|
||||||
|
```
|
||||||
|
|
||||||
## Face recognition models
|
## Face recognition models
|
||||||
|
|
||||||
Face recognition can be handled by different models. Currently, [`VGG-Face`](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) , [`Facenet`](https://sefiks.com/2018/09/03/face-recognition-with-facenet-in-keras/) and [`OpenFace`](https://sefiks.com/2019/07/21/face-recognition-with-openface-in-keras/) models are supported in deepface. The default configuration verifies faces with **VGG-Face** model. You can set the base model while verification as illustared below. Accuracy and speed show difference based on the performing model.
|
Face recognition can be handled by different models. Currently, [`VGG-Face`](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) , [`Facenet`](https://sefiks.com/2018/09/03/face-recognition-with-facenet-in-keras/) and [`OpenFace`](https://sefiks.com/2019/07/21/face-recognition-with-openface-in-keras/) models are supported in deepface. The default configuration verifies faces with **VGG-Face** model. You can set the base model while verification as illustared below. Accuracy and speed show difference based on the performing model.
|
||||||
@ -67,33 +77,35 @@ Deepface also offers facial attribute analysis including [`age`](https://sefiks.
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
from deepface import DeepFace
|
from deepface import DeepFace
|
||||||
demography = DeepFace.analyze("img.jpg") #passing nothing as 2nd argument will find everything
|
demography = DeepFace.analyze("img4.jpg") #passing nothing as 2nd argument will find everything
|
||||||
#demography = DeepFace.analyze("img.jpg", ['age', 'gender', 'race', 'emotion']) #identical to above line
|
#demography = DeepFace.analyze("img4.jpg", ['age', 'gender', 'race', 'emotion']) #identical to above line
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/tests/dataset/img4-cropped.jpg"></p>
|
||||||
|
|
||||||
Analysis function returns a json object.
|
Analysis function returns a json object.
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"age": 31.940666721338523
|
"age": 31.25149216214664
|
||||||
, "gender": "Woman"
|
, "gender": "Woman"
|
||||||
, "race": {
|
, "race": {
|
||||||
"asian": 11.314528435468674,
|
"asian": 0.43224629728474007,
|
||||||
"indian": 17.498773336410522,
|
"indian": 1.3657950678941648,
|
||||||
"black": 3.541698679327965,
|
"black": 0.05537125728443308,
|
||||||
"white": 21.96589708328247,
|
"white": 75.67231510116548,
|
||||||
"middle eastern": 19.87851709127426,
|
"middle eastern": 13.872351579210257,
|
||||||
"latino hispanic": 25.800585746765137
|
"latino hispanic": 8.601920819397021
|
||||||
}
|
}
|
||||||
, "dominant_race": "latino hispanic"
|
, "dominant_race": "white"
|
||||||
, "emotion": {
|
, "emotion": {
|
||||||
"angry": 6.004959843039945e-16,
|
"angry": 0.08186087173241338,
|
||||||
"disgust": 4.9082449499136944e-34,
|
"disgust": 2.225523142400352e-06,
|
||||||
"fear": 4.7907148065142067e-23,
|
"fear": 0.04342652618288561,
|
||||||
"happy": 100.0,
|
"happy": 90.62228091028702,
|
||||||
"sad": 4.8685008000541987e-14,
|
"sad": 1.1166408126522078,
|
||||||
"surprise": 5.66862615875019e-10,
|
"surprise": 0.6784230348078054,
|
||||||
"neutral": 3.754812086254056e-09
|
"neutral": 7.457371945067876
|
||||||
}
|
}
|
||||||
, "dominant_emotion": "happy"
|
, "dominant_emotion": "happy"
|
||||||
}
|
}
|
||||||
|
@ -80,15 +80,17 @@ def verify(img1_path, img2_path
|
|||||||
|
|
||||||
if distance <= threshold:
|
if distance <= threshold:
|
||||||
identified = True
|
identified = True
|
||||||
|
message = "The both face photos are same person."
|
||||||
else:
|
else:
|
||||||
identified = False
|
identified = False
|
||||||
|
message = "The both face photos are not same person!"
|
||||||
|
|
||||||
#-------------------------
|
#-------------------------
|
||||||
|
|
||||||
plot = False
|
plot = False
|
||||||
|
|
||||||
if plot:
|
if plot:
|
||||||
label = "Distance is "+str(round(distance, 2))
|
label = "Distance is "+str(round(distance, 2))+"\nwhereas max threshold is "+ str(threshold)+ ".\n"+ message
|
||||||
|
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
fig.add_subplot(1,2, 1)
|
fig.add_subplot(1,2, 1)
|
||||||
|
BIN
tests/dataset/img4-cropped.jpg
Normal file
BIN
tests/dataset/img4-cropped.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
tests/dataset/img4.jpg
Normal file
BIN
tests/dataset/img4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 463 KiB |
BIN
tests/dataset/test-case-1.jpg
Normal file
BIN
tests/dataset/test-case-1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
@ -2,13 +2,15 @@ from deepface import DeepFace
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
#-----------------------------------------
|
#-----------------------------------------
|
||||||
|
|
||||||
print("Facial analysis tests")
|
print("Facial analysis tests")
|
||||||
|
|
||||||
img = "dataset/img1.jpg"
|
img = "dataset/img4.jpg"
|
||||||
demography = DeepFace.analyze(img, ['age', 'gender', 'race', 'emotion'])
|
demography = DeepFace.analyze(img, ['age', 'gender', 'race', 'emotion'])
|
||||||
|
|
||||||
print("Demography:")
|
print("Demography:")
|
||||||
print(demography)
|
print(demography)
|
||||||
|
demography = json.loads(demography)
|
||||||
|
|
||||||
#check response is a valid json
|
#check response is a valid json
|
||||||
print("Age: ", demography["age"])
|
print("Age: ", demography["age"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user