访问Google Drive的文件,只需要一下代码(咱也不知道啥意思,咱也不敢问)
!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}
这个需要你进两次网站确认,而且每次运行colab的时候都要跑一遍,然后接着就是下面代码:
!mkdir -p drive
!google-drive-ocamlfuse drive
运行完之后就可以访问了,访问方法如下:
target_image_path = 'drive/文件在drive中的路径'