Go to your Google Drive and right click the dataset you want to upload to Kaggle.
Generate the shareable link and the code that comes after
https://drive.google.com/open?id=, it should be a long code (like
Insert the long code at the end of
Copy that link. Should look something like
When uploading a dataset to Kaggle, select to add a file from remote URL.
Insert copied URL.
gdown to directly download your google drive file into your session every time. The download speed is pretty high so it wont take much time.
The file id can obtained by the method described in the previous answer.
Here's the solution that works every time and very efficiently.
A) Case of file
import torchvision torchvision.datasets.utils.download_file_from_google_drive(file_id, root, filename=None, md5=None)
This download a Google Drive file and place it in root.
- file_id (str): id of file to be downloaded
- root (str): Directory to place downloaded file in
- filename (str, optional): Name to save the file under. If None, use the id of the file.
- md5 (str, optional): MD5 checksum of the download. If None, do not check
B) Case of folder
1.launch google colab and log into your google drive account.
2. zip the folder :
%cd /content/drive/"My drive"/.../my_folder
! zip -r archive_name.zip my_folder
So you can download this zip file with torchvision wherever you want (filename=archive_name.zip), and unzip it with :
! unzip archive_name.zip -d my_folder
This works for me,
pip install gdown won't work in Kaggle so follow this:
!conda install -y gdown !gdown https://drive.google.com/uc?id=ID_HERE
======================= or ==================
!conda install -y gdown import gdown url = 'https://drive.google.com/uc?id=ID_HERE' output = 'myfile.zip' gdown.download(url, output)
Your google drive id can be found from shared link