我的Google云端硬盘中有https://www.kaggle.com/puneet6060/intel-image-classification的数据集。这些文件夹已压缩。
有关如何从主文件夹访问各个zip文件夹(seg_train.zip,seg_test.zip,seg_pred.zip)的帮助? 然后,在访问zip后说seg_train.zip,如何从中访问文件夹(建筑物,冰川)?
我尝试了以下代码:
!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为
1d7-jWu8P1q3cNfcRaqSE8bybUrdl9qyW
我遇到以下错误:
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
答案 0 :(得分:1)
使用以下代码段跳过PyDrive并直接安装Google云端硬盘:
from google.colab import drive
drive.mount('/content/drive')
然后,您可以访问云端硬盘中的目录,就像它们是后端VM上的普通文件一样。