Not able to open the cloned repository from GitHub

2020-07-29 23:42发布

问题:

I want to clone a GitHub repository (experiencor/keras-yolo2). I followed the following command

!git clone https://github.com/experiencor/keras-yolo2.git

But after cloning the repository, I don't know how to run the ipynb.

I even tried uploading the files to drive and opening the ipynb. But when I execute the libraries it is showing the following error

ImportErrorTraceback (most recent call last)
<ipython-input-1-c62f96def33a> in <module>()
 14 import pickle
 15 import os, cv2
 ---> 16 from preprocessing import parse_annotation, BatchGenerator
 17 from utils import WeightReader, decode_netout, draw_boxes
 18 

  ImportError: No module named preprocessing

I understand that this error is due to the absence of 'pre-processing'library. But I don't know how to allow Golab to access the file which is saved in the same folder in the drive.

回答1:

You'll need to update your Python path.

# Clone the repo.
!git clone https://github.com/experiencor/keras-yolo2.git

# Change the working directory to the repo root.
%cd keras-yolo2

# Add the repo root to the Python path.
import sys, os
sys.path.append(os.getcwd())

Here's a complete example: https://colab.research.google.com/drive/18FUSsXztLZfedSk1OoaH5J8-NO8QSBWT