Image classification with kaggle dataset

Hi, i downloaded a kaggle image classification dataset.
It consists of a folder names “chest_xray” and the folder contains 5 folders named with their respective labels for the images in that folder.
I am using colab and i have uploaded the “chest_xray” folder to my google drive.

But i don’t know how to get it into the colab environment :confused:. Kindly help me out.

Thanks,

Hi Ajay,

Did you import the Google Drive package?

If not, feel free to use this code below:

from google.colab import drive

class DriveAccess:

def init(self):
self.mount_point = None
self.root_dir = None
self.base_dir = None

def mount_drive(self):
drive.mount(self.mount_point, force_remount=True)

@staticmethod
def unmount_drive():
drive.flush_and_unmount()

def make_folder(self, folder):
path = Path(self.base_dir)
folder_path = path/folder
folder_path.mkdir(parents=True, exist_ok=True)

drive_object = DriveAccess()
drive_object.mount_point = “/content/gdrive”
drive_object.root_dir = drive_object.mount_point+"/My Drive/"
drive_object.base_dir = drive_object.root_dir + “fastai-v3/ImageClassification/CricketVsBaseball”
drive_object.mount_drive()

X------X
The code posted above will let you mount your GDrive. In the base dir param, modify it to reflect your directory structure.

Hope this helps. If your issue was with Mounting Gdrive on colab, I recommend you to change to topic title, to reflect that for easy reference.

1 Like

Hi, Thank you.
I was able to mount the Google drive and access the file therein. :slight_smile:

Thank you,

1 Like