从 Kaggle 下载文件到 Google Colab [英] Download file from Kaggle to Google Colab

查看:57
本文介绍了从 Kaggle 下载文件到 Google Colab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将

所以它不起作用.找不到文件或返回的 zip 存档不是 101mb 大,而只有几 kb.同样在尝试解压缩时,它也不起作用.

如何将此文件下载到我的 colab 中(直接使用 wget?)?

解决方案

Kaggle 建议使用他们自己的 API 而不是 wget 或 rsync.

首先,为 Kaggle 制作一个 API 令牌.在 Kaggle 的网站上,转到我的帐户",滚动到 API 部分,然后单击创建新的 API 令牌".- 它会在你的机器上下载 kaggle.json 文件.

然后在 Google Colab 中运行以下命令:

来自 google.colab 导入文件files.upload() # 浏览你下载的 kaggle.json 文件# 创建一个名为kaggle的目录,将kaggle.json文件复制到那里,并修改文件的权限.!mkdir ~/.kaggle!cp kaggle.json ~/.kaggle/!chmod 600 ~/.kaggle/kaggle.json# 你可以通过运行这个命令来检查一切是否正常.!kaggle 数据集列表# 下载并解压手语-mnist 数据集到'/usr/local'!kaggle 数据集下载 -d datamunge/sign-language-mnist --path '/usr/local' --unzip

此处使用的信息:https://www.kaggle.com/general/74235

I want to download the sign language dataset from Kaggle to my Colab.

So far I always used wget and the specific zip file link, for example:

!wget --no-check-certificate \
    https://storage.googleapis.com/laurencemoroney-blog.appspot.com/rps.zip \
    -O /tmp/rps.zip

However, when I right-click the download button at Kaggle and select copy link to get the path copied to my clipboard and I output it I get:

https://www.kaggle.com/datamunge/sign-language-mnist/download

When I use this link in my browser I am asked to download it. I can see that the filename is 3258_5337_bundle_archive.zip

So I tried:

!wget --no-check-certificate \
        https://www.kaggle.com/datamunge/sign-language-mnist/download3258_5337_bundle_archive.zip  \
        -O /tmp/kds.zip

and also tried:

 !wget --no-check-certificate \
            https://www.kaggle.com/datamunge/sign-language-mnist/download3258_5337_bundle_archive.zip  \
            -O /tmp/kds.zip

I get as output:

So it does not work. File coudln't be found or the returned zip archive is not 101mb large, but just a few kb. Also when trying to unzip it, it does not work.

How can I download this file into my colab (directly with wget?)?

解决方案

Kaggle recommends using their own API instead of wget or rsync.

First, make an API token for Kaggle. On Kaggle's website go to "My Account", Scroll to API section and click on "Create New API Token" - It will download kaggle.json file on your machine.

Then run the following in Google Colab:

from google.colab import files
files.upload() # Browse for the kaggle.json file that you downloaded

# Make directory named kaggle, copy kaggle.json file there, and change the permissions of the file.
! mkdir ~/.kaggle
! cp kaggle.json ~/.kaggle/
! chmod 600 ~/.kaggle/kaggle.json

# You can check if everything's okay by running this command.
! kaggle datasets list

# Download and unzip sign-language-mnist dataset into '/usr/local'
! kaggle datasets download -d datamunge/sign-language-mnist --path '/usr/local' --unzip

Used info from here: https://www.kaggle.com/general/74235

这篇关于从 Kaggle 下载文件到 Google Colab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆