Python googlecolab中目录的访问

Python googlecolab中目录的访问,python,google-colaboratory,Python,Google Colaboratory,大家晚上好,我正在使用google colab,因为它支持GPU和TPU,没有它,我无法在我的计算机上运行许多深度学习代码,我已经安装了google colab,问题如下: 让我们假设我的工作目录是 在这里我可以上传图片,csv文件等,我已经搜索了很多关于这一点的资料,我发现以下 from google.colab import drive drive.mount('/content/drive') 我已经运行了这段代码并按照说明操作,最后我得到了:Mounted at/content/d

大家晚上好,我正在使用google colab,因为它支持GPU和TPU,没有它,我无法在我的计算机上运行许多深度学习代码,我已经安装了google colab,问题如下: 让我们假设我的工作目录是

在这里我可以上传图片,csv文件等,我已经搜索了很多关于这一点的资料,我发现以下

from google.colab import drive
 drive.mount('/content/drive')
我已经运行了这段代码并按照说明操作,最后我得到了:Mounted at/content/drive

之后,我将简单文件上传到此目录,并运行以下代码

from google.colab import drive
drive.mount('/content/drive')
import matplotlib.pyplot as plt
import numpy as np
import cv2
import skimage
from skimage import data
from skimage import io
Image =cv2.imread('palm.jpg')
io.imshow(Image)

AttributeError:'NoneType'对象没有属性'dtype',我搜索了有关此错误的文档,发现我的图像可能是[],那么错误的原因是什么?请帮我安装驱动器时,在目录中查找“驱动器”文件夹。您必须找到该文件夹中图像的路径。它可能类似于
img_path='/content/drive/My drive/sample.jpg'

在code'/content/drive/MyDrive/Machine Learning/OpenCV/palm.jpg'中提到图像的完整路径。

from google.colab import drive
drive.mount('/content/drive')
import matplotlib.pyplot as plt
import numpy as np
import cv2
import skimage
from skimage import data
from skimage import io
Image =cv2.imread('/content/drive/MyDrive/Machine Learning/OpenCV/palm.jpg')
io.imshow(Image)

我在这个文件夹中有图像。你在你的驱动器的目录下看到那个文件夹了吗?如果你看到了,你可以用
image=cv2.imread('content/drive/MyDrive/Machine Learning/OpenCV/palm.jpg')
替换
image=cv2.imread('/content/drive/MyDrive/Machine Learning/OpenCV/palm.jpg'))
。是否检查了当前运行这些命令的目录?完整目录是:MyDrive/Machine Learning/OpenCVCheck image extensin.jpg或.jpeg如果不起作用,请检查image extension.jpg或.jpeg