AttributeError: 'NoneType' object has no attribute 'shape' on jupyter notebook

1.6K    Asked by ajithJayaraman in Devops , Asked on Jun 16, 2021

 I am working on the image dataset using the jupyter notebook. I have no issues loading the image. But when I try displaying the image file matrix is been displayed and it keeps on giving me the error "No type Attribute". My image is saved in the same folder where my code is saved.

The code which I am using is:

imgA = cv2.imread("C:\Users\Dzaky Ligarwaly-R\Documents\pattern recognition\Biomedical_Image.jpg")

imgB = cv2.imread("C:\Users\Dzaky Ligarwaly-R\Documents\pattern recognition\pano.jpg")

The code to reshape the image is:

scale_percent = 60 # percentage of original size

# imgA

width = int(imgA.shape[1] * scale_percent / 100)

height = int(imgA.shape[0] * scale_percent / 100)

dimA = (width, height)

# imgB

width = int(imgB.shape[1] * scale_percent / 100)

height = int(imgB.shape[0] * scale_percent / 100)

dimB = (width, height)

Answered by Aditya Yadav

The 'nonetype' object has no attribute 'shape' code which you have used is completely correct but then notice the path the file is different so maybe you are having the same folder in different paths. Try looking into the path as it is a recurring mistake.



Your Answer

Interviews

Parent Categories