How to load data into Google Colab? ¶
By: sriramgs on May 28, 2024, 5:18 p.m.
Hi All, I am quite new to this platform. Would someone please share any resources explaining how to load image dataset from zenodo repository into Google Colab?
By: NataliaAlves on May 29, 2024, 7:03 a.m.
Hi Sriram,
You can download each batch directly into Google Colab using the following steps (example for batch 1):
# Step 1: Mount Google Drive
from google.colab import drive
drive.mount('/content/drive')
# Step 2: Define the download URL and the destination path in Google Drive
download_url = "https://zenodo.org/record/11034178/files/batch_1.zip"
destination_path = "/content/drive/MyDrive/batch_1.zip"
# Step 3: Download the zip file directly to Google Drive
!wget -O $destination_path $download_url
You can then unzip the file using zipfile:
import zipfile
import os
# Define the path to the zip file and the extraction directory
zip_file_path = "/content/drive/MyDrive/batch_1.zip"
extraction_dir = "/content/drive/MyDrive/batch_1/"
# Create the extraction directory if it doesn't exist
os.makedirs(extraction_dir, exist_ok=True)
# Unzip the file
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
zip_ref.extractall(extraction_dir)
print("Extraction complete.")
Hope it helps! If you have any other questions, don't hesitate to ask.
By: sriramgs on May 29, 2024, 10:32 a.m.
Hi Natalia,
Thanks for your reply. I am able to download dataset. Currently, I am using Google's free credits which comes with storage limitations. My Google drive's storage limit is 15 GB whereas 1st batch dataset is itself 40 GB. Is that imply I cannot proceed with free credits? or Is there an easier way you guys are following. Please advise.
Thanks!