• Stars
    star
    2,679
  • Rank 16,917 (Top 0.4 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MOT using deepsort and yolov3 with pytorch

Deep Sort with PyTorch

Update(1-1-2020)

Changes

  • fix bugs
  • refactor code
  • accerate detection by adding nms on gpu

Latest Update(07-22)

Changes

  • bug fix (Thanks @JieChen91 and @yingsen1 for bug reporting).
  • using batch for feature extracting for each frame, which lead to a small speed up.
  • code improvement.

Futher improvement direction

  • Train detector on specific dataset rather than the official one.
  • Retrain REID model on pedestrain dataset for better performance.
  • Replace YOLOv3 detector with advanced ones.

Any contributions to this repository is welcome!

Introduction

This is an implement of MOT tracking algorithm deep sort. Deep sort is basicly the same with sort but added a CNN model to extract features in image of human part bounded by a detector. This CNN model is indeed a RE-ID model and the detector used in PAPER is FasterRCNN , and the original source code is HERE.
However in original code, the CNN model is implemented with tensorflow, which I'm not familier with. SO I re-implemented the CNN feature extraction model with PyTorch, and changed the CNN model a little bit. Also, I use YOLOv3 to generate bboxes instead of FasterRCNN.

Dependencies

  • python 3 (python2 not sure)
  • numpy
  • scipy
  • opencv-python
  • sklearn
  • torch >= 0.4
  • torchvision >= 0.1
  • pillow
  • vizer
  • edict

Quick Start

  1. 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
  1. Clone this repository
git clone [email protected]:ZQPei/deep_sort_pytorch.git
  1. 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 ../../../
  1. 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 ../../../
  1. 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.

  1. (Optional) Prepare third party submodules

fast-reid

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.

MMDetection

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
  1. 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]

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

Training the RE-ID model

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. train.jpg

Demo videos and images

demo.avi demo2.avi

1.jpg 2.jpg

References

More Repositories

1

Sorting_Visualization

The Sound of Sorting: Visualize and Audibilize 12 classic sorting algorithms in real time
Python
285
star
2

DSSD

Pytorch implementation of DSSD (Deconvolutional Single Shot Detector)
Python
54
star
3

patchmatch_inpainting

Implementation of PatchMatch for image inpainting in cpp
C++
49
star
4

Seeded-Region-Growing-Algorithm

Seeded Region Growing Algorithm
Python
24
star
5

Haze_Removal_cpp

An c++ implementation of 《single image haze removal using dark channel prior》
C++
11
star
6

Haze_Removal_python

This is an python implementation of "single image haze removal using dark channel prior"
Python
9
star
7

ASCII-Art

把图片/电影转成字符画
Python
9
star
8

deep_joint_filter

This is an pytorch implementation of Deep Joint Filter
Python
8
star
9

transfer_learning_resnet18

基于resnet18的迁移学习分类网络,用于给bee和ant二分类
Python
7
star
10

Huster

HTTP Server with Upload tool.
Python
4
star
11

Maze

maze, dfs, 深度优先搜索
Python
4
star
12

image2html

Showing images with a html file
Python
3
star
13

AirCraft

A small game AirCraft
C
2
star
14

pybind11_cpp_python

cpp call python, or python call cpp, hybrid programming using pybind11, with and without numpy
C++
2
star
15

easyyaml

Easy yaml parser and editer
Python
2
star
16

MNIST_logistic_regression

用逻辑回归实现对手写字符的分类
Python
2
star
17

cuda_sort

1
star
18

Lenet_cifar10_pytorch

It is a Lenet CNN trained on cifar10 using pytorch
Python
1
star
19

awesome-mechine-learning-systems

1
star
20

docker_pytorch_tensorflow

This repository contains a Dockerfile for an anaconda environment with pytorch and tensorflow installed as well as oh-my-zsh, tmux and etc.
Dockerfile
1
star
21

Alibaba_Cloud_German_AI_Challenge_for_Earth_Observation

Alibaba Cloud German AI Challenge 2018, 1st Prize.
Python
1
star
22

pingan_algo_challenge

2018平安算法比赛代码分享
Python
1
star