简体   繁体   English

从 google colab 恢复 zip 文件

[英]Resuing a zip file from google colab

I am trying to train a CNN on Google Colab.我正在尝试在 Google Colab 上训练 CNN。 I have a files of 50,000 images.我有一个包含 50,000 张图像的文件。 From googling around I found the best way to use them is to zip the files and then unzip them in the notebook.通过谷歌搜索,我发现使用它们的最佳方法是压缩文件,然后在笔记本中解压缩它们。 This has been pretty tedious because it takes a while to unzip the folder and every time I want run a new model I have to re unzip the folder and it takes a ton of time.这非常乏味,因为解压缩文件夹需要一段时间,每次我想运行一个新模型时,我都必须重新解压缩文件夹,这需要大量时间。 Is there anyway to speed this up??有没有办法加快这个速度?

from google.colab import drive
drive.mount('/content/drive')
!unzip -uq "/zip folder on drive" -d "/new location folder"

Google colab is a temporary machine with temporary storage.谷歌 colab 是一个带有临时存储的临时机器。 You can only attach your drive or any other cloud storage to Colab and write scripts to automate the flow to run on every new notebook run.您只能将您的驱动器或任何其他云存储连接到 Colab 并编写脚本来自动化流程,以便在每次新笔记本运行时运行。

I use Google cloud storage and I mount it in colab whenever i need to work on it.我使用 Google 云存储,并在需要处理时将其安装在 colab 中。

This will be a bit faster than uploading and downloading through the GUI from the notepad.这比从记事本通过 GUI 上传和下载要快一些。

The code to mount your google drive to colab is将您的谷歌驱动器安装到 colab 的代码是

from google.colab import drive
drive.mount('/content/drive')

This is an example for copying这是一个复制的例子

!cp -r /content/gdrive/My\ Drive/headTrainingDatastructure/eval /content/models/research/object_detection/

For anyone wondering how to do this...对于任何想知道如何做到这一点的人......

first, zip you file containing your images and upload to Google Drive首先,将包含图像的文件压缩并上传到 Google Drive

second, in Google Colab, mount your drive其次,在 Google Colab 中,挂载您的驱动器

from google.colab import drive
drive.mount('/content/drive')

third, copy the zip folder into your local environment三、将zip文件夹复制到本地环境中

!cp "/file path with the zip image folder.zip" "whatever you want to      call the file when unzipped"

fourth, unzip in local colab into a folder you made四、将本地colab解压到自己制作的文件夹中

!unzip -uq "whatever you want to call the file when unzipped" -d "folder where you want them unzipped (or just make one up)"

You will have to do this every time, but it is super quick compared to what I was doing before您每次都必须这样做,但与我之前所做的相比,它非常快

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM