-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lack of verbosity during AttributeErrors #1029
Comments
The relevant section of code that needs amendment is in ~/.local/lib/python3.10/site-packages/deepface/commons/functions.py; # img might be path, base64 or numpy array. Convert it to numpy whatever it is.
img, img_name = load_image(img)
img_region = [0, 0, img.shape[1], img.shape[0]]
if detector_backend == "skip":
face_objs = [(img, img_region, 0)]
else:
face_objs = DetectorWrapper.detect_faces(detector_backend, img, align) |
Possibly not the perfect solution, but this works well enough. # img might be path, base64 or numpy array. Convert it to numpy whatever it is.
try:
img, img_name = load_image(img)
img_region = [0, 0, img.shape[1], img.shape[0]]
if detector_backend == "skip":
face_objs = [(img, img_region, 0)]
else:
face_objs = DetectorWrapper.detect_faces(detector_backend, img, align)
except AttributeError as e:
raise ValueError(f"Unreadable file - AttributeError occured for {img_name}: {e}")
|
Definitely, users should see a meaningful exception message. Firstly, as I see you are using an old version of DeepFace. Would you please update the package first? This may not be an issue for the current package. Instead of using try catch, I prefer to raise an error if img is None after load_image performed: https://github.com/serengil/deepface/blob/master/deepface/modules/detection.py#L77 |
Closed with PR - #1038 |
Hi,
Firstly, thank you for the great work. This code is working excellently for me 99% of the time.
Occasionally, I will come across an image that is unreadable, for whatever reason, and get an AttributeError. In the below example, it's down to "NoneType object has no attribute shape."
This Issue has been raised specifically for verbosity purposes. Could we please have the image name added to the output when an error is thrown? At the moment, I am having to manually try and trace down what image(s) have a problem, when it really aught to be in the output.
Thank you for your time.
The text was updated successfully, but these errors were encountered: