From 0d3e501df2f47c400ecc54f6dbb635f8ca047f53 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sat, 7 Mar 2020 14:01:17 +0300 Subject: [PATCH] simpler code samples --- README.md | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index a02e295..848a2f6 100644 --- a/README.md +++ b/README.md @@ -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"]) ```

@@ -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"]) ```

@@ -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/).