我从这个Kaggle链接下载了大图像训练数据作为zip
https://www.kaggle.com/c/yelp-restaurant-photo-classification/data
我如何有效地实现以下目标?
-
在Google Colaboratory中创建项目文件夹
-
将zip文件上传到项目文件夹
-
解压缩文件
谢谢
编辑:我尝试了下面的代码,但它崩溃了我的大型zip文件 . 有没有更好/更有效的方法来执行此操作,我可以在本地驱动器中指定文件的位置?
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
5 回答
第9行有一些细微的变化,没有遇到错误 . 来源:https://gist.github.com/jayspeidell/d10b84b8d3da52df723beacc5b15cb27无法添加为评论原因代表 .
你可以参考这些主题:
Import data into Google Colaboratory
Load local data files to Colaboratory
另请查看I/O example notebook . 例如,要访问
xls
文件,您需要将文件上传到Google表格 . 然后,您可以在同一I / O示例笔记本中使用gspread
配方 .您可能需要使用
kaggle-cli
模块来帮助下载 .它在this fast.ai thread中讨论过 .
我刚刚编写了这个脚本,可以将Kaggle API中的数据下载并提取到Colab笔记本中 . 您只需粘贴用户名,API密钥和竞争名称即可 .
https://gist.github.com/jayspeidell/d10b84b8d3da52df723beacc5b15cb27
Colab中的手动上传功能现在有点儿麻烦,最好通过wget或API服务下载文件,因为每次打开笔记本时都要使用新的VM . 这样数据将自动下载 .
另一个选择是将数据上传到Dropbox(如果它适合),获取下载链接 . 然后在笔记本上做