Skip to content

Commit ae5d5b9

Browse files
committed
getting rid of target_size everywhere
1 parent 1078be9 commit ae5d5b9

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ demographies = DeepFace.analyze(img_path = "img4.jpg",
237237

238238
#face detection and alignment
239239
face_objs = DeepFace.extract_faces(img_path = "img.jpg",
240-
target_size = (224, 224),
241240
detector_backend = backends[4]
242241
)
243242
```

deepface/DeepFace.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# pylint: disable=wrong-import-position
1111

1212
# 3rd party dependencies
13+
import cv2
1314
import numpy as np
1415
import pandas as pd
1516
import tensorflow as tf
@@ -532,7 +533,6 @@ def detectFace(
532533
logger.warn("Function detectFace is deprecated. Use extract_faces instead.")
533534
face_objs = extract_faces(
534535
img_path=img_path,
535-
target_size=target_size,
536536
detector_backend=detector_backend,
537537
enforce_detection=enforce_detection,
538538
align=align,
@@ -541,4 +541,5 @@ def detectFace(
541541
extracted_face = None
542542
if len(face_objs) > 0:
543543
extracted_face = face_objs[0]["face"]
544+
extracted_face = cv2.resize(extracted_face, target_size)
544545
return extracted_face

deepface/modules/recognition.py

-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ def __find_bulk_embeddings(
321321
model_name (str): Model for face recognition. Options: VGG-Face, Facenet, Facenet512,
322322
OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace and GhostFaceNet (default is VGG-Face).
323323
324-
target_size (tuple): expected input shape of facial recognition model
325-
326324
detector_backend (str): face detector model name
327325
328326
enforce_detection (bool): set this to False if you

deepface/modules/streaming.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
# project dependencies
1212
from deepface import DeepFace
13-
from deepface.models.FacialRecognition import FacialRecognition
1413
from deepface.commons.logger import Logger
1514

1615
logger = Logger(module="commons.realtime")

tests/face-recognition-how.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import matplotlib.pyplot as plt
22
import numpy as np
3+
import cv2
4+
35
from deepface import DeepFace
46
from deepface.modules import verification
57
from deepface.models.FacialRecognition import FacialRecognition
@@ -21,11 +23,13 @@
2123
# ----------------------------------------------
2224
# load images and find embeddings
2325

24-
img1 = DeepFace.extract_faces(img_path="dataset/img1.jpg", target_size=target_size)[0]["face"]
26+
img1 = DeepFace.extract_faces(img_path="dataset/img1.jpg")[0]["face"]
27+
img1 = cv2.resize(img1, target_size)
2528
img1 = np.expand_dims(img1, axis=0) # to (1, 224, 224, 3)
2629
img1_representation = model.forward(img1)
2730

28-
img2 = DeepFace.extract_faces(img_path="dataset/img3.jpg", target_size=target_size)[0]["face"]
31+
img2 = DeepFace.extract_faces(img_path="dataset/img3.jpg")[0]["face"]
32+
img2 = cv2.resize(img2, target_size)
2933
img2 = np.expand_dims(img2, axis=0)
3034
img2_representation = model.forward(img2)
3135

tests/overlay.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
img = cv2.imread(img_path)
88

99
overlay_img_path = "dataset/img6.jpg"
10-
face_objs = DeepFace.extract_faces(overlay_img_path, target_size=(112, 112))
10+
face_objs = DeepFace.extract_faces(overlay_img_path)
1111
overlay_img = face_objs[0]["face"][:, :, ::-1] * 255
1212

13+
overlay_img = cv2.resize(overlay_img, (112, 112))
14+
1315
raw_img = img.copy()
1416

1517
demographies = DeepFace.analyze(img_path=img_path, actions=("age", "gender", "emotion"))

0 commit comments

Comments
 (0)