Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load image dataset (folder or zip) located in Google Drive to Google Colab?

I have a dataset of images on my Google Drive. I have this dataset both in a compressed .zip version and an uncompressed folder.

I want to train a CNN using Google Colab. How can I tell Colab where the images in my Google Drive are?

  1. official tutorial does not help me as it only shows how to upload single files, not a folder with 10000 images as in my case.

  2. Then I found this answer, but the solution is not finished, or at least I did not understand how to go on from unzipping. Unfortunately I am unable to comment this answer as I don't have enough "stackoverflow points"

  3. I also found this thread, but here all the answer use other tools, such as Github or dropbox

I hope someone could explain me what I need to do or tell me where to find help.

Edit1:

I have found yet another thread asking the same question as mine: Sadly, of the 3 answers, two refer to Kaggle, which I don't know and don't use. The third answer provides two links. The first link refers to the 3rd thread I linked, and the second link only explains how to upload single files manually.

like image 596
charelf Avatar asked Mar 18 '18 17:03

charelf


1 Answers

I saw and tried all the above but it didn't work for me. So here is a simple solution with simple explanation that can help you load a .zip image folder and extract images from it.

  • Connect to google drive
    from google.colab import drive
    drive.mount('/content/drive')
    

(you will get a link sign in to your google account and copy the code and paste onto the code asked in the colab)

  • Install and import keras library
    !pip install -q keras
    import keras
    
    

(the zip file is loaded into the colab)

  • Unzip the folder
    ! unzip 'zip-file-path'
    

To get the path:

  • select file on left side of google colab
  • browse for the file click on the 3 dots
  • copy path

Now the unzipped image folder is loaded onto your colab use it as you wish

like image 173
Neha Avatar answered Sep 20 '22 14:09

Neha