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' #2

Closed
Testbild opened this issue Aug 22, 2021 · 2 comments
Closed

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

Testbild opened this issue Aug 22, 2021 · 2 comments

Comments

@Testbild
Copy link

Testbild commented Aug 22, 2021

Hi,
I was running the main.py and all worked well except one cell (I have been running it on google colab)

from google.colab.patches import cv2_imshow
import cv2
from CCA_Analysis import *


##Plotting - RESULT Example
img=cv2.imread("/content/drive/Images/107.png")#original img 107.png 

predict1 = cv2.resize(predict, (img.shape[1],img.shape[0]), interpolation=cv2.INTER_LANCZOS4)

mask=np.uint8(predict1*255)# 
_, mask = cv2.threshold(mask, thresh=255/2, maxval=255, type=cv2.THRESH_BINARY)
cnts,hieararch=cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
img = cv2.drawContours(img[:,:,0], cnts, -1, (255, 0, 0) , 2)
img = cv2.UMat.get(img)
cv2_imshow(img)
AttributeError                            Traceback (most recent call last)

<ipython-input-16-dfb2228e54c2> in <module>()
      7 img=cv2.imread("/content/drive/Images/107.png")#original img 107.png
      8 
----> 9 predict1 = cv2.resize(predict, (img.shape[1],img.shape[0]), interpolation=cv2.INTER_LANCZOS4)
     10 
     11 mask=np.uint8(predict1*255)#

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

Do you have any idea how to resolve this?

@SerdarHelli
Copy link
Owner

Hi Testbild,

Thanks for return. I think that the problem is misidentifing of path of "img".

We must find to path of original image.You can try:

img=cv2.imread("/content/Data/Images/107.png")

Please dont forget your feedback

@Testbild
Copy link
Author

Hi SerdarHelli,

that was the solution. Thanks. Maybe you can update the source code.

Best regards

Testbild

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