我想将图像文件存储在驱动器上,并从协作笔记本链接到它们。这可能吗?例如。
google-drive/
notebook.ipynb
images/
pic.jpg
在notebook.ipynb
降价单元格内:

答案 0 :(得分:3)
使用以下代码:
buffering
运行上述命令后,它将要求输入密钥。单击提供的链接并验证它。
使用以下方法在驱动器中创建文件夹:
!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
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
在此之后,您可以像在本地连接一样使用驱动器:
!mkdir -p colabData
!google-drive-ocamlfuse colabData
答案 1 :(得分:3)
Arpit Gupta对于图片的最佳答案的可能替代方案是公开共享的:获取文件的ID并添加此行:
https://docs.google.com/uc?export=download&id=
从forum post获取它。
答案 2 :(得分:0)
Google总是让我迷失在细节上。那就是魔鬼所在的地方。根据先前的答案,这些是我使图像可共享以便可以在笔记本中使用的步骤。