Fix `deepface` error when no images exist
Accomplished by adding another check for ValueError message Might be better to warn user if no images exist
This commit is contained in:
parent
b5d95ed963
commit
de5d6c1ab0
|
@ -60,7 +60,6 @@ def main():
|
|||
while True:
|
||||
# Grab a single frame of video
|
||||
ret, frame = video_capture.read()
|
||||
# Only process every other frame of video to save time
|
||||
# Resize frame of video to a smaller size for faster recognition processing
|
||||
run_frame = cv2.resize(frame, (0, 0), fx=args.run_scale, fy=args.run_scale)
|
||||
# view_frame = cv2.resize(frame, (0, 0), fx=args.view_scale, fy=args.view_scale)
|
||||
|
|
|
@ -124,13 +124,21 @@ def recognize_face(
|
|||
model_name="ArcFace",
|
||||
detector_backend="opencv",
|
||||
)
|
||||
except ValueError as e:
|
||||
|
||||
except (ValueError) as e:
|
||||
if (
|
||||
str(e)
|
||||
== "Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False." # noqa: E501
|
||||
):
|
||||
# print("No faces recognized") # For debugging
|
||||
return None
|
||||
elif (
|
||||
# Check if the error message contains "Validate .jpg or .png files exist in this path."
|
||||
"Validate .jpg or .png files exist in this path." in str(e)
|
||||
):
|
||||
# If a verbose/silent flag is added, this should be changed to print only if verbose is true
|
||||
# print("No faces found in database")
|
||||
return None
|
||||
else:
|
||||
raise e
|
||||
# Iteate over the dataframes
|
||||
|
|
Loading…
Reference in New Issue