【问题标题】:using a drive address from computer into google colab使用计算机中的驱动器地址进入 google colab
【发布时间】:2019-12-05 01:12:51
【问题描述】:

我是 python 和 google colab 的新手。我想在 google colab 中运行这部分代码。但我得到错误:没有这样的文件或目录......这段代码在我的电脑上运行,我得到了图像,嗯。 你能帮帮我吗?

import os
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

BASEDIR = "e:\datasets\Caltech60\train\001.ak47"

list_open =mpimg.imread(os.path.join(BASEDIR, '001_0001.jpg'))
plt.imshow(list_open)

【问题讨论】:

  • 从技术上讲,colab 笔记本在 Google 的服务器上运行,无法访问您的本地文件系统。最好的方法是将您的数据上传到谷歌驱动器并从那里加载。

标签: python google-colaboratory


【解决方案1】:

How do I import a csv file into Google Colab that uses R kernel?

这里我指出了如何将您的数据上传到 google colab,然后您必须更改您的代码 BASEDIR="001.ak47"

让我知道它是否有效,正如答案中所写,python内核有一个安装驱动器选项,以防你想使用它(正如你在问题中提到的驱动器地址)

【讨论】:

  • "001.ak47" 是一个文件夹,我无法将其上传到 colab...我应该压缩它吗?
  • 现在我明白了。是的,使用 !unzip name.zip 将其压缩并在 colab 中解压缩
  • colab 中如何解压 zip 和 tar 文件?
  • tar.7z 文件?或其他扩展?对于 zip,我编辑了评论
  • 你可以试试这个,但是我没有用过tar,通常使用rar或zip。 !apt-get install tar !tar xvf file.tar 。让我知道它是否有效
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-01
  • 2018-08-29
  • 2019-04-25
  • 2020-11-15
  • 1970-01-01
  • 1970-01-01
  • 2020-06-13
相关资源
最近更新 更多