我想从Google Colab Notbook中的驱动器中读取数据集。 我怎样才能做到这一点? 我做了类似的事情,但它没有用。
train_data_dir = "data/train/"
validation_data_dir = "data/validation/"
数据文件夹是这样的:
data/
train/
dogs/
dog001.jpg
dog002.jpg
...
cats/
cat001.jpg
cat002.jpg
...
validation/
dogs/
dog001.jpg
dog002.jpg
...
cats/
cat001.jpg
cat002.jpg
...
答案 0 :(得分:-1)
我找到了使用Drive FUSE wrapper
的解决方案你必须安装驱动器保险丝包装然后创建一个目录然后安装它,该目录是驱动器的根目录,将数据集上传到谷歌驱动器并使用“/ content / name_of_your_directory / dataset_name /”<访问它/ p>
就我而言,我遵循了以下步骤:
!apt-get update -qq 2>&1 > /dev/null
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
然后
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
prompt = !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass(prompt[0] + '\n\nEnter verification code: ')
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
!mkdir -p yourdirectory
!google-drive-ocamlfuse yourdirectory
train_data_dir = "/content/yourdirectory/data/train/"
validation_data_dir = "/content/yourdirectory/data/validation/"