How to open and work on files stored in Google drive from Google colab?

喜你入骨 提交于 2020-05-16 15:09:12

问题


So I cannot successfully install miniconda and decided to work in Google Colab. But my local repository is in Google Drive. All of the jupyter notebook that I want to work on is store in Google Drive. I want to work on them in Google Colab. However, I cannot open the files other than the ones stored in Colab folder of Google drive. What should I do now?


回答1:


  1. First you need to mount google drive and then

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

  2. Click the link on colb and authenticate (copy password and paste in colab) to mount and access your gdrive.

  3. You can access your folder as shown below path_to_data = '/content/gdrive/My Drive/MyFolder_where_data_stored' Unique_Labels_List = os.listdir(path_to_data)

  4. After running model, save the model, zip and download to local.
    !zip -r ./MyFolder.zip /content/MyFolder
    files.download("/content/MyFolder.zip")

There are many other things you can do. Check this resource for some more commands and you can find many more by searching in google. Thanks!



来源:https://stackoverflow.com/questions/61428443/how-to-open-and-work-on-files-stored-in-google-drive-from-google-colab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!