Google Colab imports GitHub python project to run

This article introduces how to import the github project containing the ipynb suffix file to GitHub for running.

import project

Colab needs a ladder.
Visit URL: https://colab.research.google.com
insert image description here
Enter the github website and press Enter. The following content is automatically obtained from github.
Select the ipynb file to be opened by the project, and use this file as the entry point for the program to run. It should be noted that you must click on that icon, not click on other places of this item.

After entering the editing page, if there is no link (the files are all empty), click the link, and then wait for a while
insert image description here

The previous operation just imported the ipynb file, and the code needs to be moved later. My example is to directly use git to pull the code up.

%%capture
%pip install ffmpeg-python imageio-ffmpeg
!git init .
!git remote add origin https://github.com/AliaksandrSiarohin/first-order-model
!git pull origin master
!git clone https://github.com/graphemecluster/first-order-model-demo demo

The project I demonstrate here has git clone in my own code, so the code is directly pulled into the file. You can also pull the code through Google cloud disk, because that solution is more troublesome than the direct git clone solution, and here you can directly refresh the code according to git pull, and the cloud disk solution is not introduced.

run project

Every piece of code can run

insert image description here
The running results will be temporarily stored on the current page corresponding to the connection, and may disappear if the page is closed.

! It is equivalent to switching to the terminal in the current directory for input

!git init .

cd needs to add a percent sign (the percent sign is a magic command of ipython)

%cd demo

Pull a file from the cloud disk to the current folder

!wget -c https://drive.google.com/file/d/1hwW8BjrlHzzG_Z4Z7uhHT73g1XLxO6PN/view?usp=share_link -O resource/vox-10segments.pth.tar

It should be noted that changing the file code may require restarting the command line to take effect (note that you need to re-cd after restarting):

import os
os.kill(os.getpid(), 9)

Details of other issues can be found on the welcome interface:
https://colab.research.google.com/

Guess you like

Origin blog.csdn.net/htwhtw123/article/details/129624269