Код: Выделить всё
# Installing kaggle to colab
!pip install kaggle
# Mounting google drive to colab
from google.colab import drive
drive.mount('/content/drive')
# Get the legacy api key from kaggle (the .json file) and upload here
from google.colab import files
files.upload()
# This happens inside colab's disk
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 ~/.kaggle/kaggle.json
# Path of your dataset (locate through colab its easier)
!kaggle datasets init -p "/content/drive/MyDrive/path_to_your_dataset"
# This part is for initializing and zipping the dataset.
import shutil
import os
# Your source folder in Google Drive
source_folder = '/content/drive/MyDrive/path_to_your_dataset'
# The destination zip file (saving it directly to Colab's temporary fast storage, NOT back to Drive)
zip_destination = '/content/name_for_your_zip'
print("Zipping started. This will take some time for 50GB...")
# This creates a file named '/content/MyDataset_Zipped.zip'
shutil.make_archive(zip_destination, 'zip', source_folder)
print("Zipping complete! Check the file browser on the left.")
# Create a temporary folder
!mkdir /content/KaggleUpload
# Move your new zip file into it
!mv /content/name_for_your_zip.zip /content/KaggleUpload/
# Initialize the metadata file.
!kaggle datasets init -p /content/KaggleUpload
### Before you proceed go to your /content/KaggleUpload/ in colab's disk and edit the .json file with the title and dataset name. This name will reflect in your kaggle (dataset by default will be private)
# The dataset that's zipped in colab's disk will be sent to kaggle
!kaggle datasets create -p /content/KaggleUpload --dir-mode skip
Подробнее здесь: https://stackoverflow.com/questions/798 ... with-colab