如何从Google colab打开和处理存储在Google驱动器中的文件? [英] How to open and work on files stored in Google drive from Google colab?
问题描述
所以我无法成功安装miniconda并决定在Google Colab中工作.但是我的本地存储库位于Google云端硬盘中.我要使用的所有jupyter笔记本都存储在Google云端硬盘中.我想在Google Colab中处理它们.但是,我无法打开Google驱动器Colab文件夹中存储的文件以外的文件.我现在该怎么办?
So I cannot successfully install miniconda and decided to work in Google Colab. But my local repository is in Google Drive. All of the jupyter notebook that I want to work on is store in Google Drive. I want to work on them in Google Colab. However, I cannot open the files other than the ones stored in Colab folder of Google drive. What should I do now?
推荐答案
-
首先,您需要安装google驱动器,然后
First you need to mount google drive and then
来自google.colab导入驱动器
drive.mount('/content/gdrive')
from google.colab import drive
drive.mount('/content/gdrive')
单击colb上的链接并进行身份验证(复制密码并粘贴到colab中)以安装和访问您的gdrive.
Click the link on colb and authenticate (copy password and paste in colab) to mount and access your gdrive.
您可以如下所示访问您的文件夹 path_to_data ='/content/gdrive/我的驱动器/MyFolder_where_data_stored' Unique_Labels_List = os.listdir(path_to_data)
You can access your folder as shown below path_to_data = '/content/gdrive/My Drive/MyFolder_where_data_stored' Unique_Labels_List = os.listdir(path_to_data)
运行模型后,保存模型,压缩并下载到本地.
!zip -r ./MyFolder.zip/content/MyFolder
files.download("/content/MyFolder.zip")
After running model, save the model, zip and download to local.
!zip -r ./MyFolder.zip /content/MyFolder
files.download("/content/MyFolder.zip")
您还可以执行许多其他操作.检查此资源中的其他命令,您可以通过在Google中搜索找到更多命令.谢谢!
There are many other things you can do. Check this resource for some more commands and you can find many more by searching in google. Thanks!
这篇关于如何从Google colab打开和处理存储在Google驱动器中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!