如何在Google Colab中显示图片? [英] How do i show an image in google Colab?

查看:1100
本文介绍了如何在Google Colab中显示图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用cv2.imshow(img)时,colab给出DisabledFunctionError( https://github.com/jupyter/notebook/issues/3935 ),所以我使用了cv2_imshow(img),该错误给出了图片所示的错误(AttributeError:"NoneType"对象没有属性"clip").

When I use cv2.imshow(img), colab gives DisabledFunctionError (https://github.com/jupyter/notebook/issues/3935) so I used cv2_imshow(img) which is giving this error as shown in picture(AttributeError: 'NoneType' object has no attribute 'clip').

推荐答案

在Google Colab中使用cv2.imshow(img)返回以下输出:

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)

这篇关于如何在Google Colab中显示图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆