From 0d7c36a63b1873a4923a4a0fd37815a93855b52b Mon Sep 17 00:00:00 2001 From: raghucharan16 Date: Thu, 27 Feb 2025 11:55:35 +0530 Subject: [PATCH] raising exceptions for model weights and 3D img checks --- deepface/models/facial_recognition/Buffalo_L.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deepface/models/facial_recognition/Buffalo_L.py b/deepface/models/facial_recognition/Buffalo_L.py index 27e4e8a..53a291d 100644 --- a/deepface/models/facial_recognition/Buffalo_L.py +++ b/deepface/models/facial_recognition/Buffalo_L.py @@ -50,7 +50,7 @@ class Buffalo_L(FacialRecognition): if os.path.exists(weights_path): logger.debug(f"Model file found at: {weights_path}") else: - logger.debug(f"Model file NOT found at: {weights_path}") + raise FileNotFoundError(f"Model file not found at: {weights_path}") # Load the model using the full absolute path self.model = get_model(weights_path) @@ -66,9 +66,11 @@ class Buffalo_L(FacialRecognition): """ if len(img.shape) == 4: img = img[0] + if len(img.shape) != 3: + raise ValueError(f"Expected image to be 3D after preprocessing, but got shape: {img.shape}") if img.max() <= 1.0: img = (img * 255).astype(np.uint8) - img = img[:, :, ::-1] + img = img[:, :, ::-1] # Convert RGB to BGR return img def forward(self, img: np.ndarray) -> List[float]: