mirror of
https://github.com/serengil/deepface.git
synced 2025-06-10 13:27:08 +00:00
Merge pull request #1038 from serengil/feat-task-2402-bug-fixes-and-improvements
Feat task 2402 bug fixes and improvements
This commit is contained in:
commit
5c420c53bb
@ -19,7 +19,7 @@ from deepface.modules import (
|
|||||||
recognition,
|
recognition,
|
||||||
demography,
|
demography,
|
||||||
detection,
|
detection,
|
||||||
realtime,
|
streaming,
|
||||||
)
|
)
|
||||||
from deepface import __version__
|
from deepface import __version__
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ def stream(
|
|||||||
time_threshold = max(time_threshold, 1)
|
time_threshold = max(time_threshold, 1)
|
||||||
frame_threshold = max(frame_threshold, 1)
|
frame_threshold = max(frame_threshold, 1)
|
||||||
|
|
||||||
realtime.analysis(
|
streaming.analysis(
|
||||||
db_path=db_path,
|
db_path=db_path,
|
||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
detector_backend=detector_backend,
|
detector_backend=detector_backend,
|
||||||
|
@ -43,8 +43,15 @@ class YoloClient(Detector):
|
|||||||
|
|
||||||
# Download the model's weights if they don't exist
|
# Download the model's weights if they don't exist
|
||||||
if not os.path.isfile(weight_path):
|
if not os.path.isfile(weight_path):
|
||||||
|
logger.info(f"Downloading Yolo weights from {WEIGHT_URL} to {weight_path}...")
|
||||||
|
try:
|
||||||
gdown.download(WEIGHT_URL, weight_path, quiet=False)
|
gdown.download(WEIGHT_URL, weight_path, quiet=False)
|
||||||
logger.info(f"Downloaded YOLO model {os.path.basename(weight_path)}")
|
except Exception as err:
|
||||||
|
raise ValueError(
|
||||||
|
f"Exception while downloading Yolo weights from {WEIGHT_URL}."
|
||||||
|
f"You may consider to download it to {weight_path} manually."
|
||||||
|
) from err
|
||||||
|
logger.info(f"Yolo model is just downloaded to {os.path.basename(weight_path)}")
|
||||||
|
|
||||||
# Return face_detector
|
# Return face_detector
|
||||||
return YOLO(weight_path)
|
return YOLO(weight_path)
|
||||||
|
@ -76,6 +76,9 @@ def extract_faces(
|
|||||||
# img might be path, base64 or numpy array. Convert it to numpy whatever it is.
|
# img might be path, base64 or numpy array. Convert it to numpy whatever it is.
|
||||||
img, img_name = preprocessing.load_image(img_path)
|
img, img_name = preprocessing.load_image(img_path)
|
||||||
|
|
||||||
|
if img is None:
|
||||||
|
raise ValueError(f"Exception while loading {img_name}")
|
||||||
|
|
||||||
base_region = FacialAreaRegion(x=0, y=0, w=img.shape[1], h=img.shape[0], confidence=0)
|
base_region = FacialAreaRegion(x=0, y=0, w=img.shape[1], h=img.shape[0], confidence=0)
|
||||||
|
|
||||||
if detector_backend == "skip":
|
if detector_backend == "skip":
|
||||||
|
@ -176,7 +176,7 @@ def analysis(
|
|||||||
|
|
||||||
demographies = DeepFace.analyze(
|
demographies = DeepFace.analyze(
|
||||||
img_path=custom_face,
|
img_path=custom_face,
|
||||||
detector_backend=detector_backend,
|
detector_backend="skip",
|
||||||
enforce_detection=False,
|
enforce_detection=False,
|
||||||
silent=True,
|
silent=True,
|
||||||
)
|
)
|
||||||
@ -411,7 +411,7 @@ def analysis(
|
|||||||
img_path=custom_face,
|
img_path=custom_face,
|
||||||
db_path=db_path,
|
db_path=db_path,
|
||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
detector_backend=detector_backend,
|
detector_backend="skip",
|
||||||
distance_metric=distance_metric,
|
distance_metric=distance_metric,
|
||||||
enforce_detection=False,
|
enforce_detection=False,
|
||||||
silent=True,
|
silent=True,
|
||||||
@ -429,7 +429,7 @@ def analysis(
|
|||||||
display_img = cv2.imread(label)
|
display_img = cv2.imread(label)
|
||||||
# to use extracted face
|
# to use extracted face
|
||||||
source_objs = DeepFace.extract_faces(
|
source_objs = DeepFace.extract_faces(
|
||||||
img_path=label,
|
img_path=display_img,
|
||||||
target_size=(pivot_img_size, pivot_img_size),
|
target_size=(pivot_img_size, pivot_img_size),
|
||||||
detector_backend=detector_backend,
|
detector_backend=detector_backend,
|
||||||
enforce_detection=False,
|
enforce_detection=False,
|
Loading…
x
Reference in New Issue
Block a user