JorgeMunnozAguado / seq_nms_yolo

This project combines YOLOv2 and seq-nms to realise real time video detection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Seq_nms_YOLO

Introduction

This project combines YOLOv2(reference) and seq-nms(reference) to realise real time video detection.

Steps to execute

  1. Download yolo.weights and tiny-yolo.weights by running

    wget https://pjreddie.com/media/files/yolo.weights
    wget https://pjreddie.com/media/files/yolov2-tiny-voc.weights -O tiny-yolo-voc.weights
    
  2. 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
    
  3. Make sure that paths are correctly setted.

    export PATH=/usr/local/cuda-10.1/bin:$PATH
    
  4. 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 lines 49 & 51. If don't have GPU just write GPU=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 set OpenCV=0.

  5. 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)

  6. In the video folder, run python video2img.py -i input_file and then run python get_pkllist.py.

  7. Return to root floder and run python yolo_seqnms.py to generate output images in video/output folder.

    From the label_map_util.py file in original repository we need to change tf.gfile.GFil by tf.io.gfile.GFile as the previous function is deprecated.

  8. 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 changed cv2.cv.CV_FOURCC(*'mp4v') by cv2.VideoWriter_fourcc(*'mp4v') as the previous functions was not able. In the same file we commented cv2.destroyAllWindows() function as libgtk2.0-dev is not currently installed.

  9. At last you will see output.mp4 file with detection results in video/ folder.

Use Yolov2 without Seq-NMS

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.

Reference

This project copies lots of code from darknet , Seq-NMS and models.

Videos come from UCF-101 dataset.

About

This project combines YOLOv2 and seq-nms to realise real time video detection.


Languages

Language:C 85.5%Language:Cuda 8.1%Language:Python 5.7%Language:C++ 0.3%Language:Makefile 0.3%