当前位置:网站首页>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
边栏推荐
猜你喜欢
Diffusion模型详解
Pit encountered by vs2015 under win7 (successful)
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)
【无标题】
Applet sliding, clicking and switching simple UI
Use 3 in data modeling σ Eliminate outliers for data cleaning
细说Mysql MVCC多版本控制
Future development blueprint of agriculture and animal husbandry -- vertical agriculture + artificial meat
Win10安装VS2015
官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展
随机推荐
PostgreSQL reports an error when creating a trigger,
Natapp intranet penetration
Can flycdc use SqlClient to specify mysqlbinlog ID to execute tasks
Gauss elimination
Write VBA in Excel, connect to Oracle and query the contents in the database
洛谷P2482 [SDOI2010]猪国杀
Application of C # XML
根据热门面试题分析Android事件分发机制(一)
Win10安装VS2015
企业实战|复杂业务关系下的银行业运维指标体系建设
Delete a record in the table in pl/sql by mistake, and the recovery method
中国首款电音音频类“山野电音”数藏发售来了!
arcgis操作:dwg数据转为shp数据
用flinksql的方式 写进 sr的表,发现需要删除的数据没有删除,参照文档https://do
HCIP 第一天 笔记整理
There is a problem using Chinese characters in SQL. Who has encountered it? Such as value & lt; & gt;` None`
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
The new activity of "the arrival of twelve constellations and goddesses" was launched
Selenium+bs4 parsing +mysql capturing BiliBili Tarot data
Basic chapter: take you through notes