问题
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.
- Login to your google account
- Access
colab.research.google.com - Select the
GitBubtab. - Choose
include private reposif needed. - Go through the authentication process in the new opened window
- 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