This project is adapted from https://github.com/melodiepupu/seq_nms_yolo to simplify the execution of Seq-NMS and YOLOv2 approaches for video object detection.
This project combines YOLOv2(reference) and seq-nms(reference) to realise real time video detection. This tutorial is designed for Linux with Anaconda.
- Open a terminal or Anaconda Prompt.
- Clone the repository and open the folder:
git clone https://github.com/sergiomcgd/seq_nms.git
cd seq_nms
Now we are ready to create an Anaconda environment, to do this you can follow steps 3 and 4 or you can just load the environment from the provided .yml file doing: conda env create -f Yolo_env.yml
. In case you choose the last option, you should jump to step 5.
-
Create an environment (manually):
conda create --name Yolo_env python=2.7
(make sure that you install python 2.7 as all the code is implemented using this Python version.)source activate Yolo_env
-
Install the following libraries:
- cv2:
conda install -c conda-forge opencv
- matplotlib:
conda install matplotlib
- scipy:
conda install -c anaconda scipy
- tensorflow:
conda install -c anaconda tensorflow-gpu
- pillow:
conda install -c anaconda pillow
- tf_object_detection:
conda install -c conda-forge tf_object_detection
- cv2:
-
Make the project (make sure that the environment is activated, if not, activate it with
source activate Yolo_env
):make
- Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables:
export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.1/lib64
-
Download weights and tiny weights
wget https://pjreddie.com/media/files/yolo.weights
wget https://pjreddie.com/media/files/yolo-tiny.weights
-
Copy a video file to the video folder (/seq_nms/video)
-
In the video folder (/seq_nms/video) run video2img.py and get_pkllist.py:
cd video
python video2img.py -i video.avi
python get_pkllist.py
-
Return to root folder and run
python yolo_seqnms.py
to generate output images invideo/output
;cd ..
python yolo_seqnms.py
-
To obtain a video from the resulting output images go to video folder and run
img2video.py
cd video
python img2video.py -i output
The results would be available in the video folder.
This project copies lots of code from darknet , Seq-NMS and models.
Some instructions were extracted from: https://docs.nvidia.com/cuda/cuda-quick-start-guide/index.html