当前位置:网站首页>Google Colab装载Google Drive(Google Colab中使用Google Drive)
Google Colab装载Google Drive(Google Colab中使用Google Drive)
2022-07-07 07:19:00 【iioSnail】
文章目录
为什么要在Google Colab中使用Google Drive
一般有如下几个原因:
- 上传慢:本地文件上传到Google Colab中太慢,要是session过期了,可能还要反复上传。但如果把文件传到Google Drive上,那么就可以直接从Google Drive上拿,只需要上传一遍即可。
- 数据丢失:Google Colab会话容易过期,导致模型和训练数据丢失,所以可以定期将数据和模型存到Google Drive中,这样就不怕丢了,而且对于后续接着训练很方便。
- 有些公开的数据集是Google Drive链接,可以很方便的加载它们。
装载Google Drive
当我们进入Colab页面后,点击文件,然后点击装载Google Colab:

之后可能会生成一段代码(也有可能不生成,直接就装载成功了):
from google.colab import drive
drive.mount('/content/drive')
然后运行该代码(第一次会弹出个框进行确认),之后就会发现文件列表多了一个drive文件夹,这下面就是你Google Drive的文件内容:

之后你对该文件夹的操作都会同步到你的Google Drive中。
从Google Drive中下载文件
装载好Google Drive后,直接用里面的文件就行了,例如:
!unzip drive/MyDrive/Datasets/wider_yolo.zip
我这里解压了我Google Drive中Datasets/wider_yolo.zip文件。

写入文件到Google Drive
装载好Google Drive后,只要将文件写入到drive/MyDrive下面的目录下即可。例如:
with open('drive/MyDrive/test.txt', mode='w') as f:
f.write("Deep Learning")
执行完上述命令后,MyDrive目录下生成了test.txt文件。

此时去Google Drive里也可以看到该文件。

Google Colab下载Google Drive共享文件
例如,有这么一个共享文件链接:
https://drive.google.com/file/d/1xmkOQ1p6R2T44yZw55wNivPATAieyja9/view?usp=sharing
然后取出/d/和/view/之间的文件id:1xmkOQ1p6R2T44yZw55wNivPATAieyja9
然后执行下面命令即可:
!gdown --id '1xmkOQ1p6R2T44yZw55wNivPATAieyja9' --output test.txt
边栏推荐
- Pit encountered by vs2015 under win7 (successful)
- CodeForces - 1324D Pair of Topics(二分或双指针)
- 高斯消元
- arcgis操作:dwg数据转为shp数据
- 2016 CCPC Hangzhou Onsite
- 农牧业未来发展蓝图--垂直农业+人造肉
- Application of C # XML
- CentOS installs JDK1.8 and mysql5 and 8 (the same command 58 in the second installation mode is common, opening access rights and changing passwords)
- Software modeling and analysis
- Database multi table Association query problem
猜你喜欢

Impression notes finally support the default markdown preview mode

Applet sliding, clicking and switching simple UI

arcgis操作:dwg数据转为shp数据

Lesson 1: finding the minimum of a matrix

Basic chapter: take you through notes

20排位赛3

CentOS installs JDK1.8 and mysql5 and 8 (the same command 58 in the second installation mode is common, opening access rights and changing passwords)

Flex flexible layout

First issue of JS reverse tutorial

【ORM框架】
随机推荐
【原创】程序员团队管理的核心是什么?
C socke server, client, UDP
sql 里面使用中文字符判断有问题,哪位遇到过?比如value<>`无`
请教个问题,我用sql-client起了个同步任务,从MySQL同步到ADB,历史数据有正常同步过去
Can't connect to MySQL server on '(10060) solution summary
“十二星座女神降临”全新活动推出
Sword finger offer II 107 Distance in matrix
**Grafana installation**
HCIP 第一天 笔记整理
Lesson 1: finding the minimum of a matrix
【无标题】
Lesson 1: hardness of eggs
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
Applet sliding, clicking and switching simple UI
CodeForces - 1324D Pair of Topics(二分或双指针)
Application of C # XML
Performance optimization record of the company's product "yunzhujia"
C# Socke 服务器,客户端,UDP
[4g/5g/6g topic foundation-146]: Interpretation of white paper on 6G overall vision and potential key technologies-1-overall vision
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消