Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update devel branch
  • Loading branch information
adipandas committed Nov 13, 2020
commit 6ec7536dff801ee05ec56d5149a67ad4e58d5286
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.ipynb_checkpoints/
video_data/
examples/video_data/
.idea/
examples/output.avi
pretrained_models/caffemodel_weights/
pretrained_models/tensorflow_weights/
pretrained_models/yolo_weights/
examples/pretrained_models/caffemodel_weights/
examples/pretrained_models/tensorflow_weights/
examples/pretrained_models/yolo_weights/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
76 changes: 35 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
[cars-yolo-output]: ./assets/cars.gif "Sample Output with YOLO"
[cows-tf-ssd-output]: ./assets/cows.gif "Sample Output with SSD"
[cars-yolo-output]: examples/assets/cars.gif "Sample Output with YOLO"
[cows-tf-ssd-output]: examples/assets/cows.gif "Sample Output with SSD"

# Multi-object trackers in Python
Object detection using deep learning and multi-object tracking

[![DOI](https://zenodo.org/badge/148338463.svg)](https://zenodo.org/badge/latestdoi/148338463)

### Available Trackers
```
SimpleTracker
### Available Multi Object Trackers

SimpleTracker2
```
CentroidTracker
CentroidKF_Tracker
IOUTracker
SORT
```

#### YOLO
Video Source: [link](https://flic.kr/p/89KYXt)

![Cars with YOLO][cars-yolo-output]
### Available OpenCV-based object detectors:

#### Tensorflow-SSD-MobileNet
Video Source: [link](https://flic.kr/p/26WeEWy)
```
detector.TF_SSDMobileNetV2
detector.Caffe_SSDMobileNet
detector.YOLOv3
```

![Cows with tf-SSD][cows-tf-ssd-output]
`YOLOv3 + CentroidTracker` | `TF-MobileNetSSD + CentroidTracker`
:-------------------------:|:-------------------------:
![Cars with YOLO][cars-yolo-output] | ![Cows with tf-SSD][cows-tf-ssd-output]
Video source: [link](https://flic.kr/p/89KYXt) | Video source: [link](https://flic.kr/p/26WeEWy)


### Installation
Expand All @@ -43,54 +48,43 @@ cd multi-object-tracker
pip install -e .
```

### YOLO
For using the opencv `dnn`-based object detection modules provided in this repository with GPU, you may have to compile a CUDA enabled version of OpenCV from source.

For building opencv from source, you can refer the following: [[link-1](https://docs.opencv.org/master/df/d65/tutorial_table_of_content_introduction.html)], [[link-2](https://www.pyimagesearch.com/2020/02/03/how-to-use-opencvs-dnn-module-with-nvidia-gpus-cuda-and-cudnn/)]

### How to use?: Examples

Examples for how to use `motrackers` are provided [examples](./examples/) folder of this repository.
You can clone and run the examples as shown in the [readme](examples/readme.md) inside the [examples](./examples/) folder.

### Pretrained Object Detection Models

Do the following in the terminal to download a pretrained weights of YOLO:
You will have to download the pretrained weights for the model. The shell scripts for downloading are provided in [examples](examples/) folder.

##### YOLOv3
```
cd ./pretrained_models/yolo_weights
cd ./examples/pretrained_models/yolo_weights
sudo chmod +x ./get_yolo.sh
./get_yolo.sh
```

### TensorFlow model

Do the following in the terminal to download a pretrained model:
##### TensorFlow MobileNetSSDv2
```
cd ./pretrained_models/tensorflow_weights
sudo chmod +x ./get_ssd_model.sh
./get_ssd_model.sh
```

**SSD-Mobilenet_v2_coco_2018_03_29** was used for this example.
Other networks can be downloaded and ran: Go through `tracking-tensorflow-ssd_mobilenet_v2_coco_2018_03_29.ipynb` for more details.

### Caffemodel

Do the following in the terminal to download a pretrained model:
##### Caffemodel
```
cd ./pretrained_models/caffemodel_weights
sudo chmod +x ./get_caffemodel.sh
./get_caffemodel.sh
```

This is a MobileNet-SSD caffemodel.

### Examples and How to use:

For examples and how to use this repository, please refer [examples/](examples/) folder.

### References and Credits
This work is based on the following literature:
1. Bochinski, E., Eiselein, V., & Sikora, T. (2017, August). High-speed tracking-by-detection without using image information. In 2017 14th IEEE International Conference on Advanced Video and Signal Based Surveillance (AVSS) (pp. 1-6). IEEE. [[paper-pdf](http://elvera.nue.tu-berlin.de/files/1517Bochinski2017.pdf)]
2. Pyimagesearch [link-1](https://www.pyimagesearch.com/2018/07/23/simple-object-tracking-with-opencv/), [link-2](https://www.pyimagesearch.com/2018/11/12/yolo-object-detection-with-opencv/)
3. [correlationTracker](https://github.com/Wenuka/correlationTracker)
4. [Caffemodel zoo](http://caffe.berkeleyvision.org/model_zoo.html)
5. [Caffemodel zoo GitHub](https://github.com/BVLC/caffe/tree/master/models)
6. [YOLO v3](https://pjreddie.com/media/files/papers/YOLOv3.pdf)

Use the caffemodel zoo from the reference [4,5] mentioned above to vary the CNN models and Play around with the codes.

***Suggestion**: If you are looking for speed go for SSD-mobilenet. If you are looking for accurracy and speed go with YOLO. The best way is to train and fine tune your models on your dataset. Although, Faster-RCNN gives more accurate object detections, you will have to compromise on the detection speed as it is slower as compared to YOLO.*
Please see [references.md](REFERENCES.md)

### Citation

Expand Down
13 changes: 13 additions & 0 deletions REFERENCES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# References and Credits

This work is based on the following literature:

1. Bochinski, E., Eiselein, V., & Sikora, T. (2017, August). High-speed tracking-by-detection without using image information. In 2017 14th IEEE International Conference on Advanced Video and Signal Based Surveillance (AVSS) (pp. 1-6). IEEE. [[pdf](http://elvera.nue.tu-berlin.de/files/1517Bochinski2017.pdf)]
2. Bewley, A., Ge, Z., Ott, L., Ramos, F., & Upcroft, B. (2016, September). Simple online and realtime tracking. In 2016 IEEE International Conference on Image Processing (ICIP) (pp. 3464-3468). IEEE. [[arxiv](https://arxiv.org/abs/1602.00763)]
3. YOLOv3. [[pdf](https://pjreddie.com/media/files/papers/YOLOv3.pdf)][[website](https://pjreddie.com/darknet/yolo/)]
4. Kalman Filter. [[wiki](https://en.wikipedia.org/wiki/Kalman_filter)]
5. TensorFlow Object Detection API [[github](https://github.com/tensorflow/models/tree/master/research/object_detection)]
6. Caffe [[website](https://caffe.berkeleyvision.org/)][[github](https://github.com/BVLC/caffe)]


#### Link to `multi-object-tracker` [[webpage](https://adipandas.github.io/multi-object-tracker/)][[GitHub Repo](https://github.com/adipandas/multi-object-tracker)]
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
title: Multi-object trackers in Python
description:
theme: jekyll-theme-cayman
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"source": [
"import numpy as np\n",
"import cv2 as cv\n",
"from motrackers import IOUTracker\n",
"from motrackers.utils import select_caffemodel, select_videofile"
"from motrackers.utils import select_caffemodel, select_videofile\n",
"from motrackers.iou_tracker import IOUTracker\n",
"from motrackers.detectors.caffe import Caffe_MobileNetSSD"
]
},
{
Expand All @@ -23,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -32,7 +33,7 @@
"# display(video_file, prototxt, weights)\n",
"\n",
"video_file = \"./../video_data/people.mp4\"\n",
"prototxt = \"./../pretrained_models/caffemodel_weights/MobileNetSSD_deploy.prototxt\" \n",
"prototxt = \"./../pretrained_models/caffemodel_weights/MobileNetSSD_deploy.prototxt\"\n",
"weights = \"./../pretrained_models/caffemodel_weights/MobileNetSSD_deploy.caffemodel\""
]
},
Expand Down Expand Up @@ -156,6 +157,7 @@
" image_resized, model[\"pixel_std\"], model[\"input_size\"], \n",
" (model[\"pixel_mean\"], model[\"pixel_mean\"], model[\"pixel_mean\"]), False\n",
" )\n",
" \n",
" net.setInput(blob)\n",
" detections = net.forward()\n",
"\n",
Expand Down Expand Up @@ -192,7 +194,7 @@
" boxes.append([left, top, width, height])\n",
" confidences.append(float(confidence))\n",
" classIDs.append(int(class_id))\n",
" \n",
"\n",
" indices = cv.dnn.NMSBoxes(boxes, confidences, model[\"confidence_threshold\"], model[\"threshold\"])\n",
" \n",
" class_ids_to_track = []\n",
Expand Down Expand Up @@ -222,7 +224,7 @@
" cv.FILLED)\n",
" \n",
" cv.putText(image, label, (x, y_label), cv.FONT_HERSHEY_SIMPLEX, 0.5, clr, 2)\n",
" \n",
" \n",
" tracks = tracker.update(detections_bbox, class_ids_to_track, confidences_track)\n",
" \n",
" if print_tracks:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import cv2 as cv\n",
"from motrackers import SimpleTracker\n",
"# from motrackers import SimpleTracker\n",
"from motrackers.utils import select_caffemodel, select_videofile"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1d3c3a3a86324074b3461a40bda983ea",
"model_id": "cb30715c81274880b0f1ff9b0bab206f",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -34,7 +34,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "46b604d3ae4d4853aa0a644f9edfe463",
"model_id": "14f91c21118d4e2ba2135fcdb0bbcce7",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -48,7 +48,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9f31f72dfb7446b29e258b97fa8f1a2f",
"model_id": "e256f1517fd44cbd9b1b89e950550807",
"version_major": 2,
"version_minor": 0
},
Expand Down
Loading