This project combines YOLOv2(reference) and seq-nms(reference) to realise real time video detection.
-
Download
yolo.weights
andtiny-yolo.weights
by runningwget https://pjreddie.com/media/files/yolo.weights wget https://pjreddie.com/media/files/yolov2-tiny-voc.weights -O tiny-yolo-voc.weights
-
While downloading the previous files create a Conda enviroment.
conda create -y --name YOLOv2 python=2.7 conda activate YOLOv2 conda install -y -c conda-forge opencv conda install -y matplotlib Pillow scipy tensorflow conda install -y -c conda-forge tf_object_detection
-
Make sure that paths are correctly setted.
export PATH=/usr/local/cuda-10.1/bin:$PATH
-
make
the project.If you have a NVIDIA GPU you could set
GPU=1
. Also you might need to change the path of CUDA in lines49 & 51
. If don't have GPU just writeGPU=0
.If you want to use OpenCV set the flag
OpenCV=1
. If you want to use it but don't know how installed https://docs.opencv.org/3.3.1/d7/d9f/tutorial_linux_install.html. If you don't want to use it just setOpenCV=0
. -
Copy a video file to the video folder. (We added next videos as examples:
v_ApplyEyeMakeup_g19_c03.avi
,v_ApplyLipstick_g21_c01.avi
,v_Archery_g07_c01.avi
,v_BabyCrawling_g11_c01.avi
,v_BalanceBeam_g18_c01.avi
) -
In the video folder, run
python video2img.py -i input_file
and then runpython get_pkllist.py
. -
Return to root floder and run
python yolo_seqnms.py
to generate output images invideo/output
folder.From the
label_map_util.py
file in original repository we need to changetf.gfile.GFil
bytf.io.gfile.GFile
as the previous function is deprecated. -
If you want to reconstruct a video from these output images, you can go to the video folder and run
python img2video.py -i output
.From the
img2video.py
file in original repository we changedcv2.cv.CV_FOURCC(*'mp4v')
bycv2.VideoWriter_fourcc(*'mp4v')
as the previous functions was not able. In the same file we commentedcv2.destroyAllWindows()
function aslibgtk2.0-dev
is not currently installed. -
At last you will see
output.mp4
file with detection results invideo/
folder.
In order to deactivate Seq-NMS post-processing add to the python yolo_seqnms.py
execution --seq_nms 0
flag.
If we want to deactivate the NMS delating non relevant detections add to the execution --nms 0
flag.
This project copies lots of code from darknet , Seq-NMS and models.
Videos come from UCF-101 dataset.