How to run a downloaded Jupyter notebook on Google Colaboratory?

随声附和 提交于 2019-12-03 12:27:17

问题


I am using Google Colaboratory & github. I create a new Google Colab notebook, and I clone my github project into it using a simple !git clone <github_link> in the notebook.

Now, I have a Jupyter notebook in my github project that I need to run on Google Colab. How do I do that?


回答1:


There is not a real need of downloading the notebook. If you already have your Notebook in a GitHub repo, the only thing you need to do is:

  • Open your Notebook file on GitHub in any browser (So the URL ends in .ipynb).
  • Change the URL from https://github/full_path_to_your_notebook to https://colab.research.google.com/github/full_path_to_your_notebook

And that should work.




回答2:


You can upload the notebook to google drive first, then open it from there.

  • go to drive.google.com
  • go into directory “Colab Notebooks”
  • choose “New” > File upload
  • After uploading, click the new file
  • Chose “Open with Colaboratory” at the top



回答3:


One of the way could be that you can connect your google drive with the Colaboraty notebook using the following link:

Link to images within google drive from a colab notebook

Post which you can download your github repo in your google drive location. Then browse through your google drive and open the notebook using Colaboratory itself.




回答4:


The two most practical ways are both through the Google Drive webinterface.

The first method is what @Korakot Choavavanich described. The advantage of this method is that it provides a Search window to search for your file in your google drive storage.

The second method is even more convenient - and maybe more appropriate for your case:

In the Google Drive webinterface, you navigate to your folder where your file is located - in your case within the cloned github repository.

Then (see screenshot):

right-click on the file | Open with | Colaboratory

Your file is then converted into a colabo notebook automatically (it takes at least half a minute for that). The advantage with this method is that you can create the colabo file directly in the folder. My tip is to create a copy of the original jupyter file (I added "COLABO" in the file name) as you will have different code to sync your google drive and save files than in a local jupyter notebook.




回答5:


import sys, os

sys.path.append('models/research')

sys.path.append('models/research/object_detection')

It helped me. I was also looking for it, and found it in this COLAB work

https://colab.research.google.com/drive/1EQ3Lt_ez-oKTtVMebh6Tm3XSyPPOHAf3#scrollTo=oC-_mxCxCNP6




回答6:


It may be a new feature not mentioned in other answers. But right now Colab allows running jupyter notebooks directly from github, even from private repos.

  1. Login to your google account
  2. Access colab.research.google.com
  3. Select the GitBub tab.
  4. Choose include private repos if needed.
  5. Go through the authentication process in the new opened window
  6. Select from your repos and notebooks

And clone your repo from inside the opened notebook.



来源:https://stackoverflow.com/questions/48961866/how-to-run-a-downloaded-jupyter-notebook-on-google-colaboratory

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