simpler code samples

This commit is contained in:
Sefik Ilkin Serengil 2020-03-07 14:01:17 +03:00 committed by GitHub
parent b128ee10f9
commit 0d3e501df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,9 @@ Verify function under the DeepFace interface is used for face recognition.
```python
from deepface import DeepFace
result = DeepFace.verify("img1.jpg", "img2.jpg")
print("Is verified: ", result["verified"])
print("Distance: ", result["distance"])
```
<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/tests/dataset/test-case-2.jpg" width="50%" height="50%"></p>
@ -27,13 +30,6 @@ result = DeepFace.verify("img1.jpg", "img2.jpg")
}
```
You can retrieve the fields of the response object easily in Python.
```python
print("Is verified: ", result["verified"])
print("Distance: ", result["distance"])
```
Each call of verification function builds a face recognition model from scratch and this is a costly operation. If you are going to verify multiple faces sequentially, then you should pass an array of faces to verification function to speed the operation up. In this way, complex face recognition models will be built once.
```python
@ -79,8 +75,12 @@ Deepface also offers facial attribute analysis including [`age`](https://sefiks.
from deepface import DeepFace
demography = DeepFace.analyze("img4.jpg") #passing nothing as 2nd argument will find everything
#demography = DeepFace.analyze("img4.jpg", ['age', 'gender', 'race', 'emotion']) #identical to the line above
#demographies = DeepFace.analyze(["img1.jpg", "img2.jpg", "img3.jpg"]) #analyzing multiple faces same time
demographies = DeepFace.analyze(["img1.jpg", "img2.jpg", "img3.jpg"]) #analyzing multiple faces same time
print("Age: ", demography["age"])
print("Gender: ", demography["gender"])
print("Emotion: ", demography["dominant_emotion"])
print("Emotion: ", demography["dominant_race"])
```
<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/tests/dataset/test-case-1.jpg" width="20%" height="20%"></p>
@ -113,14 +113,6 @@ Analysis function returns a json object.
}
```
Then, you can retrieve the fields of the response object easily in Python.
```python
print("Age: ", demography["age"])
print("Gender: ", demography["gender"])
print("Emotion: ", demography["dominant_emotion"])
```
# Installation
The easiest way to install deepface is to download it from [PyPI](https://pypi.org/project/deepface/).