From ab38a1fcf7c9aba9fe31f9243a189b36f847b9ca Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sat, 24 Feb 2024 15:31:50 +0000 Subject: [PATCH] throw meaningful error if yolo weights failed while downloading --- deepface/detectors/Yolo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/deepface/detectors/Yolo.py b/deepface/detectors/Yolo.py index ed88e63..debafc3 100644 --- a/deepface/detectors/Yolo.py +++ b/deepface/detectors/Yolo.py @@ -43,8 +43,15 @@ class YoloClient(Detector): # Download the model's weights if they don't exist if not os.path.isfile(weight_path): - gdown.download(WEIGHT_URL, weight_path, quiet=False) - logger.info(f"Downloaded YOLO model {os.path.basename(weight_path)}") + logger.info(f"Downloading Yolo weights from {WEIGHT_URL} to {weight_path}...") + try: + gdown.download(WEIGHT_URL, weight_path, quiet=False) + 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 YOLO(weight_path)