Deep SORT and YOLO v4 for people tracking and detection with Tensorflow backend.
With asynchronous processing
As you can see in the gif, asynchronous processing has better FPS but causes stuttering.
This code only detects and tracks people, but can be changed to detect other objects by changing lines 101 and 102 in yolo.py:
if predicted_class != 'person': continue
Please note that Deep SORT is only trained on tracking people, so you'd need to train a model yourself for tracking other objects.
Real-time FPS with video writing:
- ~4.3fps with YOLO v3
- ~10.6fps with YOLO v4
YOLO v4 performs much faster and appears to be more stable than YOLO v3. All tests were done using an Nvidia GTX 1070 8gb GPU
and an i7-8700k CPU.
Download and convert the Darknet YOLO v4 model to a Keras model by modifying convert.py accordingly and run:
Then run demo.py:
By default, video writing is turned on and asynchronous processing is turned off. These can be edited in demo.py by changing:
writeVideo_flag = True asyncVideo_flag = False
To change target file in demo.py:
file_path = 'video.webm'
To change output settings in demo.py:
out = cv2.VideoWriter('output_yolov4.avi', fourcc, 30, (w, h))
Training your own YOLO v4 model
- Tensorflow GPU 1.14
- Keras 2.3.1
- opencv-python 4.2.0
- imutils 0.5.3
- numpy 1.18.2
Subscribe to Python Awesome
Get the latest posts delivered right to your inbox