1

I have dataset from https://www.kaggle.com/puneet6060/intel-image-classification that I have in my Google drive. These folders are zipped.

Help needed with How do I access individual zip folders(seg_train.zip,seg_test.zip,seg_pred.zip) from the main folder? Then, after accessing the zip, say seg_train.zip, how to access folders (building,glaciers) from that?

I tried below code:

    !pip install PyDriveimport os
    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    from google.colab import auth
    from oauth2client.client import GoogleCredentials
    auth.authenticate_user()
    gauth = GoogleAuth()
    gauth.credentials = GoogleCredentials.get_application_default()
    drive = GoogleDrive(gauth)
    download = drive.CreateFile({'id': '1d7-jWu8P1q3cNfcRaqSE8bybUrdl9qyW'})
    download.GetContentFile('data.zip')
    !unzip data.zip

ID of the main folder being

1d7-jWu8P1q3cNfcRaqSE8bybUrdl9qyW

I am getting below error:

FileNotDownloadableError                  Traceback (most recent call last)
<ipython-input-9-db7681c14c0b> in <module>()
----> 1 download.GetContentFile('data.zip')
      2 get_ipython().system('unzip data.zip')

2 frames
/usr/local/lib/python3.6/dist-packages/pydrive/files.py in FetchContent(self, mimetype, remove_bom)
    263     else:
    264       raise FileNotDownloadableError(
--> 265         'No downloadLink/exportLinks for mimetype found in metadata')
    266 
    267     if mimetype == 'text/plain' and remove_bom:

FileNotDownloadableError: No downloadLink/exportLinks for mimetype found in metadata

enter image description here

enter image description here

user10089194
  • 339
  • 1
  • 5
  • 14

1 Answers1

2

Skip PyDrive and mount your Google Drive directly using this snippet:

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

Then, you can access directories in Drive just as though they were normal files on the backend VM.

Bob Smith
  • 36,107
  • 11
  • 98
  • 91
  • Can you elaborate? Suppose I want to access the Intel Image Classification Data folder as shown in 2nd image. How do I do that? – user10089194 Sep 06 '19 at 18:40
  • 1
    Use the [Drive backup & sync](https://www.google.com/drive/download/backup-and-sync/) client on your desktop to sync that directory with Drive. Then, use the snippet above to connect to your Drive files on Colab, and you'll see the directory. – Bob Smith Sep 06 '19 at 22:19