Google Colab从Google云端硬盘读取数据(图像)的速度非常慢 [英] Google Colab very slow reading data (images) from Google Drive

查看:1514
本文介绍了Google Colab从Google云端硬盘读取数据(图像)的速度非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将Google云端硬盘连接到Google Colab:

 #加载云端硬盘帮助程序并安装
从google.colab导入驱动器

#这将提示您进行授权。
drive.mount('/ content / drive')

现在当我想阅读时一系列包含驱动器中的图像的文件夹,与PC相比,它运行非常慢!



我注意到,如果我第二次运行代码,则文件夹



您对这个问题有什么建议吗?
谢谢。

解决方案

对我来说最好的方法是压缩文件,然后将其解压缩到VM磁盘中


将文件读取到VM磁盘比从云端硬盘单独读取每个文件要快得多。


假设您拥有所需的映像或本地计算机中的数据文件夹中的数据。压缩数据以获取Data.zip并将其上传到云端硬盘(如果您仅在云端硬盘上存储这些文件,也可以在其中压缩它们)。


现在,安装驱动器并运行以下命令:


!解压缩 / content / drive /我的驱动器/路径/到/Data.Zip -d``/ content''


现在修改所有数据路径以通过/ content / Data,读取图像会快得多。 / p>

**根据我对上一个问题的回答进行了调整,但最初我看了两个问题都没有用。


I connected my Google Drive to Google Colab with this code:

# Load the Drive helper and mount
from google.colab import drive

# This will prompt for authorization.
drive.mount('/content/drive')

Now when I want to read a series of folders containing images in my drive, it runs very slow compared to my pc!

And I've noticed that if I run the code a second time, folders which have been already read in the previous run are loaded faster.

Do you have any suggestions for this problem? Thanks.

解决方案

The best method for me has been to compress the files, then decompress them into the VM disk.

Reading the file into the VM disk is SO much faster than reading each file individually from Drive.

Let's say you have the desired images or data in your local machine in a folder Data. Compress Data to get Data.zip and upload it to Drive (if you only have these files on Drive, you can compress them there as well).

Now, mount your drive and run the following command:

!unzip "/content/drive/My Drive/path/to/Data.Zip" -d "/content"

Now amend all your data paths to go through /content/Data, and reading your images will be much much faster.

**Adapted from my answer to a previous question, but I initially looked at both questions to no avail.

这篇关于Google Colab从Google云端硬盘读取数据(图像)的速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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