throw meaningful error if an img_path cannot be read

This commit is contained in:
Sefik Ilkin Serengil 2024-03-02 11:57:21 +00:00
parent d3f7cab119
commit a9cb7b96e3

View File

@ -85,26 +85,31 @@ def verify(
model: FacialRecognition = modeling.build_model(model_name) model: FacialRecognition = modeling.build_model(model_name)
target_size = model.input_shape target_size = model.input_shape
# img pairs might have many faces try:
img1_objs = detection.extract_faces( img1_objs = detection.extract_faces(
img_path=img1_path, img_path=img1_path,
target_size=target_size, target_size=target_size,
detector_backend=detector_backend, detector_backend=detector_backend,
grayscale=False, grayscale=False,
enforce_detection=enforce_detection, enforce_detection=enforce_detection,
align=align, align=align,
expand_percentage=expand_percentage, expand_percentage=expand_percentage,
) )
except ValueError as err:
raise ValueError("Exception while processing img1_path") from err
img2_objs = detection.extract_faces( try:
img_path=img2_path, img2_objs = detection.extract_faces(
target_size=target_size, img_path=img2_path,
detector_backend=detector_backend, target_size=target_size,
grayscale=False, detector_backend=detector_backend,
enforce_detection=enforce_detection, grayscale=False,
align=align, enforce_detection=enforce_detection,
expand_percentage=expand_percentage, align=align,
) expand_percentage=expand_percentage,
)
except ValueError as err:
raise ValueError("Exception while processing img2_path") from err
# -------------------------------- # --------------------------------
distances = [] distances = []
regions = [] regions = []