Awesome Open Source
Awesome Open Source


The purpose of this little project is to add object tracking to yolov2 and achieve real-time multiple object tracking.

The current architecture is set to only track one type of objects, but it should be easy to generalise over all objects.

Currently support people tracking (as the provided weights for deep_sort were trained on people tracking)


opencv 3
tensorflow 1.0

for using sort :





1 - Clone this repository : git clone

2 - Initialize all submodules: git submodule update --init --recursive

3 - Go to darkflow directory and do in place build: python3 build_ext --inplace

Getting started

Download the weights :

Read more about YOLO (in darknet) and download weight files here,In case the weight file cannot be found, thtrieu has uploaded some of his here, which include yolo-full and yolo-tiny of v1.0, tiny-yolo-v1.1 of v1.1 and yolo, tiny-yolo-voc of v2.

The artchitecture I used/tested in this project is cfg/yolo.cfg with the weights bin/yolo.weights.

Next you need to download the deep_sort weights here (networks folder), provided by nwojke

The deep_sort weights provided by nwojke has been cancelled. you can get them from here instead ( thanks to @louxy126 )

extract the folder and copy it to deep_sort/resources

Edit Flags in following your configuration :

  • demo : path to video file to use, set to "camera" if you wish to use your camera

  • model : what model configuration to use for YOLO, you can get more information and .cfg files in here(put them in darkflow/cfg/ folder)

  • load : The corresponding weights to use with the chosen model (put them in darkflow/bin/) more info in here

  • threshold : the confidance threshold of the YOLO detections

  • gpu : How much GPU to use, 0 means use cpu

  • track : to activate tracking or Not

  • trackObj: which objects to track as a list (notice that deep_sort's encoder was only trained on people , so you need train your own encoder, more information in here)

  • saveVideo : whether to save video or not

  • BK_MOG : add opencv's MOG background subtraction module, only useful when YOLO can't detect people in a video (low quality, ...) use it to detect boxes around moving objects

  • tracker : which tracker to use : "deep_sort" or "sort"

          **NOTE** : "deep_sort" only supports people tracking as it was only trained to track people(the code for training is not yet published)
          **TODO** : add support for GOTURN tracker(tensorflow implementation)
          **TODO** : add support for opencv trackers (MIL,KCF,TLD,MEDIANFLOW)
  • skip : skip frames to increase fps, might decrease accuracy !

  • csv : save csv file of detections in the format (frame_id,object_id,x,y,w,h)

  • display : display video while processing or Not

Next you just have to run python, and enjoy !

Some numbers :

`speed using yolo.cfg:

YOLO with track Flag set to False : 30fps

YOLO with track Flag set to True (deep_sort) : 14 fps

YOLO with track and background subtraction Flags set to True : 10.5 fps

Tests done on (1024, 1280, 3) resolution video on Nvidia GTX 1080

skipping up to 3 frames allows for more speed up while keeping accuracy of tracking`

Disclamer :

this project is using code forked from:

thtrieu/darkflow: for the real-time object detections and classifications.

nwojke/deep_sort: for Simple Online Realtime Tracking with a Deep Association Metric.

Please follow the links to get an understanding of all the features of each project.


Yolov2 :

  title={YOLO9000: Better, Faster, Stronger},
  author={Redmon, Joseph and Farhadi, Ali},
  journal={arXiv preprint arXiv:1612.08242},

deep_sort :

  title={Simple Online and Realtime Tracking with a Deep Association Metric},
  author={Wojke, Nicolai and Bewley, Alex and Paulus, Dietrich},
  journal={arXiv preprint arXiv:1703.07402},

sort :

  author={Bewley, Alex and Ge, Zongyuan and Ott, Lionel and Ramos, Fabio and Upcroft, Ben},
  booktitle={2016 IEEE International Conference on Image Processing (ICIP)},
  title={Simple online and realtime tracking},
  keywords={Benchmark testing;Complexity theory;Detectors;Kalman filters;Target tracking;Visualization;Computer Vision;Data Association;Detection;Multiple Object Tracking},

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (1,126,504
Machine Learning (30,119
Deep Learning (22,370
Tensorflow (12,571
Image Processing (5,082
Convolutional Neural Networks (3,653
Deep Neural Networks (2,793
Real Time (2,635
Object Detection (2,485
Tracker (894
Sort (745
Yolo (609
Mobile Development (565
Darknet (297
Related Projects