extrace faces crashes for some images:
Closed this issue · 3 comments
GwydionJon commented
Traceback (most recent call last):
File "/home/gwydion/SSC/missinformation/AMMICO/ammico/testing_all.py", line 18, in <module>
).analyse_image()
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/faces.py", line 139, in analyse_image
return self.facial_expression_analysis()
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/faces.py", line 187, in facial_expression_analysis
faces = RetinaFace.extract_faces(self.subdict["filename"])
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/retinaface/RetinaFace.py", line 190, in extract_faces
img = get_image(img_path)
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/retinaface/RetinaFace.py", line 53, in get_image
if len(img.shape) != 3 or np.prod(img.shape) == 0:
AttributeError: 'NoneType' object has no attribute 'shape'
GwydionJon commented
The same image also crashes ObjectDetector
Traceback (most recent call last):
File "/home/gwydion/SSC/missinformation/AMMICO/ammico/testing_all.py", line 34, in <module>
).analyse_image()
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/objects.py", line 48, in analyse_image
self.subdict = ObjectDetector.od_client.analyse_image(self.subdict)
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/objects.py", line 24, in analyse_image
return self.detector.analyse_image(subdict)
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/objects_cvlib.py", line 73, in analyse_image
objects = self.analyse_image_from_file(subdict["filename"])
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/objects_cvlib.py", line 64, in analyse_image_from_file
objects = self.detect_objects_cvlib(image_path)
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/ammico/objects_cvlib.py", line 54, in detect_objects_cvlib
_, label, _ = cv.detect_common_objects(img)
File "/home/gwydion/anaconda3/envs/test_ammico/lib/python3.10/site-packages/cvlib/object_detection.py", line 77, in detect_common_objects
Height, Width = image.shape[:2]
AttributeError: 'NoneType' object has no attribute 'shape'
GwydionJon commented
This also happens for some other pictures.
iulusoy commented
The problem with this image is that it is a gif and not a jpg. Apparently cv2.imread()
, which is used in the underlying libraries to open the image, cannot read gifs (due to license issues?).