Attribute error 'NoneType' object has no attribute 'clip'

from google.colab.patches import cv2_imshow
from google.colab import drive 
import cv2
img = cv2.imread('/content/gdrive/MyDrive/11.jpg')

The current behavior:

Traceback (most recent call last)
in () 1 from google.colab.patches import cv2_imshow
----> 2 cv2_imshow(img)

/usr/local/lib/python3.6/dist-packages/google/colab/patches/ in cv2_imshow(a)
20 image.
21 """
---> 22 a = a.clip(0, 255).astype('uint8')
23 # cv2 stores colors as BGR; convert to RGB
24 if a.ndim == 3:

Attribute error 'NoneType' object has no attribute 'clip' 

the first paragraph is the code that i wrote one my colab,
and the second paragraph is the error that showed on the colab.
is there anyone who knows how to solve,

Attribute error ‘NoneType’ object has no attribute ‘clip’ ?

always the same with those python folks –
you’re feeding in an empty / invalid image to cv2_imshow(a)

trace back where a comes from, if it is from cv2.imread()
you MUST check, if it returned something valid

1 Like

thank you for answering me. i’ll check it.