This is an implement of MOT tracking algorithm deep sort. Currently, the project supports models of the mainstream yolo series model. This project add the existing yolo detection model algorithm (YOLOv3, YOLOV4, YOLOV4Scaled, YOLOV5, YOLOV6, YOLOV7, YOLOV8, YOLOX, YOLOR, PPYOLOE). Therefore, it is sometimes called the following name:
- YOLOv3-DeepSort
- YOLOV4-DeepSort
- YOLOV4Scaled-DeepSort
- YOLOV5-DeepSort
- YOLOV6-DeepSort
- YOLOV7-DeepSort
- YOLOV8-DeepSort
- YOLOX-DeepSort
- YOLOR-DeepSort
- PPYOLOE-DeepSort
Also, this project is compatible with the original object detection model structure. Individual training and inference of the detection model can be performed.
- MMDet
- YOLOv3
- YOLOV4
- YOLOV4Scaled
- YOLOV5
- YOLOV6
- YOLOV7
- YOLOV8
- YOLOX
- YOLOR
- PPYOLOE
- deepsort-reid
- fast-reid
Expand
yolovx_deepsort_pytorch/
βββ 001.avi
βββ checkpoint
βββ configs
β βββ deep_sort.yaml
β βββ fastreid.yaml
β βββ mmdet.yaml
β βββ ppyoloe.yaml
β βββ yolor.yaml
β βββ yolov3_tiny.yaml
β βββ yolov3.yaml
β βββ yolov4Scaled.yaml
β βββ yolov4.yaml
β βββ yolov5.yaml
β βββ yolov6.yaml
β βββ yolov7.yaml
β βββ yolox.yaml
βββ deep_sort
β βββ deep
β βββ deep_sort.py
β βββ __init__.py
β βββ __pycache__
β βββ README.md
β βββ sort
βββ deepsort.py
βββ demo
β βββ 1.jpg
β βββ 2.jpg
β βββ demo.gif
βββ detector
β βββ __init__.py
β βββ MMDet
β βββ PPYOLOE
β βββ __pycache__
β βββ YOLOR
β βββ YOLOv3
β βββ YOLOV4
β βββ YOLOV4Scaled
β βββ YOLOV5
β βββ YOLOV6
β βββ YOLOV7
β βββ YOLOX
βββ LICENSE
βββ models
β βββ deep_sort_pytorch
β βββ ppyoloe
β βββ readme.md
β βββ yolor
β βββ yolov3
β βββ yolov4
β βββ yolov4-608
β βββ yolov4Scaled
β βββ yolov5
β βββ yolov6
β βββ yolov7
β βββ yolox
βββ output
β βββ ppyoloe
β βββ README.MD
β βββ yolor
β βββ yolov3
β βββ yolov4
β βββ yolov4Scaled
β βββ yolov5
β βββ yolov6
β βββ yolov7
β βββ yolox
βββ ped_det_server.py
βββ README.md
βββ requirements.txt
βββ results_analysis
β βββ analysis.py
βββ scripts
β βββ yoloe.sh
β βββ yolor.sh
β βββ yolov3_deepsort.sh
β βββ yolov3_tiny_deepsort.sh
β βββ yolov4_deepsort.sh
β βββ yolov4Scaled_deepsort.sh
β βββ yolov5_deepsort.sh
β βββ yolov6_deepsort.sh
β βββ yolov7_deepsort.sh
β βββ yolox_deepsort.sh
βββ thirdparty
β βββ fast-reid
β βββ mmdetection
βββ train.jpg
βββ tutotial
β βββ Hungarian_Algorithm.ipynb
β βββ kalman_filter.ipynb
β βββ kalman_filter.py
βββ utils
β βββ asserts.py
β βββ draw.py
β βββ evaluation.py
β βββ __init__.py
β βββ io.py
β βββ json_logger.py
β βββ log.py
β βββ parser.py
β βββ __pycache__
β βββ tools.py
βββ webserver
β βββ config
β βββ images
β βββ __init__.py
β βββ readme.md
β βββ rtsp_threaded_tracker.py
β βββ rtsp_webserver.py
β βββ server_cfg.py
β βββ templates
βββ yolov3_deepsort_eval.py
Expand
See this requirements.txt
for more detail.
- python 3 (python2 not sure)
- numpy
- scipy
- opencv-python
- sklearn
- torch >= 0.4
- torchvision >= 0.1
- pillow
- vizer
- edict
Expand
- Check all dependencies installed
pip install -r requirements.txt
for user in china, you can specify pypi source to accelerate install like:
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
- Clone this repository
git clone https://github.com/xuarehere/yolovx_deepsort_pytorch.git
- Download YOLOv3 parameters
cd detector/YOLOv3/weight/
wget https://pjreddie.com/media/files/yolov3.weights
wget https://pjreddie.com/media/files/yolov3-tiny.weights
cd ../../../
- Download deepsort parameters ckpt.t7
cd deep_sort/deep/checkpoint
# download ckpt.t7 from
https://drive.google.com/drive/folders/1xhG0kRH1EX5B9_Iz8gQJb7UNnn_riXi6 to this folder
cd ../../../
- Compile nms module
cd detector/YOLOv3/nms
sh build.sh
cd ../../..
Notice:
If compiling failed, the simplist way is to **Upgrade your pytorch >= 1.1 and torchvision >= 0.3" and you can avoid the troublesome compiling problems which are most likely caused by either gcc version too low
or libraries missing
.
- (Optional) Prepare third party submodules
This library supports bagtricks, AGW and other mainstream ReID methods through providing an fast-reid adapter.
to prepare our bundled fast-reid, then follow instructions in its README to install it.
Please refer to configs/fastreid.yaml
for a sample of using fast-reid. See Model Zoo for available methods and trained models.
This library supports Faster R-CNN and other mainstream detection methods through providing an MMDetection adapter.
to prepare our bundled MMDetection, then follow instructions in its README to install it.
Please refer to configs/mmdet.yaml
for a sample of using MMDetection. See Model Zoo for available methods and trained models.
Run
git submodule update --init --recursive
- Run demo
usage: deepsort.py [-h]
[--fastreid]
[--config_fastreid CONFIG_FASTREID]
[--mmdet]
[--config_mmdetection CONFIG_MMDETECTION]
[--config_detection CONFIG_DETECTION]
[--config_deepsort CONFIG_DEEPSORT] [--display]
[--frame_interval FRAME_INTERVAL]
[--display_width DISPLAY_WIDTH]
[--display_height DISPLAY_HEIGHT] [--save_path SAVE_PATH]
[--cpu] [--camera CAM]
VIDEO_PATH
# yolov3 + deepsort
python deepsort.py [VIDEO_PATH]
# yolov3_tiny + deepsort
python deepsort.py [VIDEO_PATH] --config_detection ./configs/yolov3_tiny.yaml
# yolov3 + deepsort on webcam
python3 deepsort.py /dev/video0 --camera 0
# yolov3_tiny + deepsort on webcam
python3 deepsort.py /dev/video0 --config_detection ./configs/yolov3_tiny.yaml --camera 0
# fast-reid + deepsort
python deepsort.py [VIDEO_PATH] --fastreid [--config_fastreid ./configs/fastreid.yaml]
# MMDetection + deepsort
python deepsort.py [VIDEO_PATH] --mmdet [--config_mmdetection ./configs/mmdet.yaml]
# yolov4 + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov4/001 --config_detection ./configs/yolov4.yaml --detect_model yolov4
# yolov4Scaled + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov4Scaled/001 --config_detection ./configs/yolov4Scaled.yaml --detect_model yolov4Scaled
# yolov5 + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov5/001 --config_detection ./configs/yolov5.yaml --detect_model yolov5
# yolov6 + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov6/001 --config_detection ./configs/yolov6.yaml --detect_model yolov6
# yolov7 + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov7/001 --config_detection ./configs/yolov7.yaml --detect_model yolov7
# yolov8 + deepsort on video
python3 deepsort.py ./001.avi --save_path ./output/yolov8/001 --detect_model yolov8 --config_detection ./configs/yolov8.yaml
# yolox + deepsort on video
python deepsort.py ./001.avi --save_path ./output/yolox/001 --config_detection ./configs/yolox.yaml --detect_model yolox
# yolor + deepsort on video
python deepsort.py ./001.avi --save_path ./output/yolor/001 --config_detection ./configs/yolor.yaml --detect_model yolor
# ppyoloe + deepsort on video
python deepsort.py ./001.avi --save_path ./output/ppyoloe/001 --config_detection ./configs/ppyoloe.yaml --detect_model ppyoloe
Use --display
to enable display.
Results will be saved to ./output/results.avi
and ./output/results.txt
.
All files above can also be accessed from BaiduDisk!
linkerοΌBaiduDisk
passwdοΌfbuw
Expand
Switch to model directory, see README.MD for more details.
For example:
cd detector/YOLOV5
# see detector/YOLOV5/README.md for more details
see detector/{model}/README.md
for more details.
For example:
cd detector/YOLOV5
python train.py --img 640 --data VOC.yaml --cfg yolov5s.yaml --weight ../../models/yolov5/yolov5s.pt --batch-size 64 --epochs 100
or See this link for more detail
see detector/{model}/README.md
for more details.
cd detector/YOLOV5/
python detect.py --source ../../001.avi --weights ../../models/yolov5/v4.0/yolov5s.pt --device 1
Validate a model's accuracy on datasets.
see detector/{model}/README.md
for more details.
cd detector/YOLOV5/
python val.py --weights ../../models/yolov5/v4.0/yolov5s.pt --data coco.yaml --img 640 --half
Expand
The original model used in paper is in original_model.py, and its parameter here original_ckpt.t7.
To train the model, first you need download Market1501 dataset or Mars dataset.
Then you can try train.py to train your own parameter and evaluate it using test.py and evaluate.py.
Dataset
python prepare_data.py --data_dir {data_path}/Market-1501-v15.09.15
Train
$ cd ./deep_sort/deep/train.py
$ python train.py --data-dir /workspace/dataset/Market-1501/Market-1501-v15.09.15/pytorch/ --interval 10 --gpu-id 0
yolov5, v7