How Do I Show An Image In Google Colab?
When I use cv2.imshow(img) colab throws a DisabledFunctionError (https://github.com/jupyter/notebook/issues/3935). Using cv2_imshow(img) I am getting another error, AttributeError
Solution 1:
Using cv2.imshow(img) in Google Colab returns this output:
DisabledFunctionError: cv2.imshow() is disabled in Colab, because it causes Jupyter sessions
to crash; see https://github.com/jupyter/notebook/issues/3935.
As a substitution, consider using
from google.colab.patches import cv2_imshow
Accordingly, you can simply use:
from google.colab.patches import cv2_imshow
import matplotlib.pyplot as plt
img = "yourImage.png"
img = cv2.imread(img) # reads image
plt.imshow(img)
Solution 2:
Try this:
from google.colab.patches import cv2_imshow
cv2_imshow(img)
Post a Comment for "How Do I Show An Image In Google Colab?"