Colab Attribute Error #44

Open
opened 2021-07-07 22:45:36 +02:00 by diskreet90 · 3 comments
diskreet90 commented 2021-07-07 22:45:36 +02:00 (Migrated from github.com)

Love this project, and the demo project/colab works fine if I don't touch the demo image and the demo video, but as soon as I change either one to test it with my own samples I get an error. Can someone help tell me what I'm doing wrong, or missing?

Here's the output it gives me when it fails.

`AttributeError Traceback (most recent call last)
in ()
23 # img_a = Image.open(pic_a).convert('RGB')
24 img_a_whole = cv2.imread(pic_a)
---> 25 img_a_align_crop, _ = app.get(img_a_whole,crop_size)
26 img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB))
27 img_a = transformer_Arcface(img_a_align_crop_pil)

1 frames
/usr/local/lib/python3.7/dist-packages/insightface/model_zoo/scrfd.py in detect(self, img, threshold, input_size, max_num, metric)
202 input_size = self.input_size if input_size is None else input_size
203
--> 204 im_ratio = float(img.shape[0]) / img.shape[1]
205 model_ratio = float(input_size[1]) / input_size[0]
206 if im_ratio>model_ratio:

AttributeError: 'NoneType' object has no attribute 'shape'`

Love this project, and the demo project/colab works fine if I don't touch the demo image and the demo video, but as soon as I change either one to test it with my own samples I get an error. Can someone help tell me what I'm doing wrong, or missing? Here's the output it gives me when it fails. `AttributeError Traceback (most recent call last) <ipython-input-14-e700f02f7473> in <module>() 23 # img_a = Image.open(pic_a).convert('RGB') 24 img_a_whole = cv2.imread(pic_a) ---> 25 img_a_align_crop, _ = app.get(img_a_whole,crop_size) 26 img_a_align_crop_pil = Image.fromarray(cv2.cvtColor(img_a_align_crop[0],cv2.COLOR_BGR2RGB)) 27 img_a = transformer_Arcface(img_a_align_crop_pil) 1 frames /usr/local/lib/python3.7/dist-packages/insightface/model_zoo/scrfd.py in detect(self, img, threshold, input_size, max_num, metric) 202 input_size = self.input_size if input_size is None else input_size 203 --> 204 im_ratio = float(img.shape[0]) / img.shape[1] 205 model_ratio = float(input_size[1]) / input_size[0] 206 if im_ratio>model_ratio: AttributeError: 'NoneType' object has no attribute 'shape'`
woctezuma commented 2021-07-07 23:09:41 +02:00 (Migrated from github.com)

I think the face was not detected. Try lowering the detection threshold https://github.com/neuralchen/SimSwap/issues/39 or resizing the image https://github.com/deepinsight/insightface/issues/1052.

I think the face was not detected. Try lowering the detection threshold https://github.com/neuralchen/SimSwap/issues/39 or resizing the image https://github.com/deepinsight/insightface/issues/1052.
NNNNAI commented 2021-07-09 10:33:39 +02:00 (Migrated from github.com)

I think the face was not detected. Try lowering the detection threshold #39 or resizing the image deepinsight/insightface#1052.

The solution provided by @woctezuma is correct, you can have a try~.Many thanks~.

> I think the face was not detected. Try lowering the detection threshold #39 or resizing the image [deepinsight/insightface#1052](https://github.com/deepinsight/insightface/issues/1052). The solution provided by @woctezuma is correct, you can have a try~.Many thanks~.
g-i-o-r-g-i-o commented 2021-07-17 12:44:37 +02:00 (Migrated from github.com)

Sometimes it fails on files that worked until an hour before :-)
I've done "factory reset runtime", and now it seems to work (before it gave an error in the first seconds of execution).

Sometimes it fails on files that worked until an hour before :-) I've done "factory reset runtime", and now it seems to work (before it gave an error in the first seconds of execution).
Sign in to join this conversation.