Skip to content
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

'NoneType' object has no attribute 'shape' #62

Open
anjanaouseph opened this issue Mar 4, 2020 · 1 comment
Open

'NoneType' object has no attribute 'shape' #62

anjanaouseph opened this issue Mar 4, 2020 · 1 comment

Comments

@anjanaouseph
Copy link

Hey first of all thanks for this great tutorial!
I have encountered this error while running the code:

#PyTorch Variables for images
im_batches = list(map(prep_image, loaded_ims, [inp_dim for x in range(len(imlist))]))
#List containing dimensions of original images
im_dim_list = [(x.shape[1], x.shape[0]) for x in loaded_ims]
im_dim_list = torch.FloatTensor(im_dim_list).repeat(1,2)

AttributeError Traceback (most recent call last)
in ()
----> 1 im_batches = list(map(prep_image, loaded_ims, [inp_dim for x in range(len(imlist))]))
2
3 #List containing dimensions of original images
4 im_dim_list = [(x.shape[1], x.shape[0]) for x in loaded_ims]
5 im_dim_list = torch.FloatTensor(im_dim_list).repeat(1,2)

1 frames
in letterbox_image(img, inp_dim)
1 def letterbox_image(img, inp_dim):
2 '''resize image with unchanged aspect ratio using padding'''
----> 3 img_w, img_h = img.shape[1], img.shape[0]
4 w, h = inp_dim
5 new_w = int(img_w * min(w/img_w, h/img_h))

AttributeError: 'NoneType' object has no attribute 'shape'
--------------------------------------------------------------------------------------------------------------How can this be resolved?

@kalikhademi
Copy link

You should double check if the loaded image has properly read the opencv image. I had the same error and when I checked it did not have the absolute path to read the image to make imlist and later loaded_ims.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants