Skip to main content

Deep Sort ReID

Banner Image

API Docs is not yet available, but it's on the way!

Navigation

Introduction

Deep Sort ReID is an adaption of the prominent 'Deep Sort' Algorithm introduced in 2017, through the following repo and paper. After all these years, Deep Sort still stand out today as a relative simple, modular, lightweight and efficient tracking algorithm. Unfortunately, the original implementation has been abandoned for many years, and usually requires some customisation to make it work with a modern versions of Python and its dependencies.

Tracking example of 2 persons

This particular implementation of Deep Sort is an attempt to create a better codebase and add some interesting features to the original algorithm. A common issue with many open-source projects in Python is that they are completely untyped, which hurts debugging and readability. Thus, this project is shipped with Pydantic types, for data validation and usability. The original implementation also had a somewhat messy structure, where many methods didn't feel like they belonged, and other parts being somewhat hard to read. As a result, efforts have been made to improve it. We also use PyTorch instead of NumPy for most parts.

Something obviously missing from the initial attempt of this algorithm is re-identification, which is also clearly stated. With the inherited modularity of this algorithm, it's not particularly hard to add some basic support for re-identifiation. This is useful when a tracker gets obscured by some other object and then re-appears, as the algorithm can use the features of it to re-assign its previous tracker id without creating a new one. Though, I believe those parts of the project comes with room for improvements. This can be seen in the following example. Note how the multiple of the selected objects gets obscured and re-appear in the frame, and succesfully re-identified.

ReID in action

Unfortunately, this doesn't work perfectly for all situations, and it heavily depends of the selected hyperparameters, and the input of the algorithm, namely the quality of the detection boxes and extracted features.

Anyway, a long term goal is to keep improving on this tracker and add more hyperparameters and features, so that it can continue to excell as a lightweight and modular tracker option for many Computer Vision projects.

Cars

Quick Start

To start, use:

pip install deep_sort_reid

In the example.py file, you can find a general flow that uses YOLO for object detection, and then a metric learning model as a feature extractor on the detected objects. Those are then passed into the DeepSortReid class, and for the given results, we plot them on the video with cv2.

Given detections and features, we can simply call the library as:

from deep_sort_reid.DeepSortReid import DeepSortReid
from deep_sort_reid.types.tracker import TrackResult
from deep_sort_reid.types.detection import Detection
from typing import List

# First dimension is frame index and second is object within that frame
# Here we assume that features as Torch tensors are added to every detection
detections: List[List[Detection]] = [...]

deep_sort_reid = DeepSortReid(metric_type="cosine")
track_results: List[List[TrackResult]] = deep_sort_reid.track(detections)

Metadata

Release files for deep-sort-reid 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for deep-sort-reid 0.1.7
File Size Uploaded
deep_sort_reid-0.1.7.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for deep-sort-reid 0.1.7
File Interpreter ABI Platform
deep_sort_reid-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 64.0 kB

Release files / deep_sort_reid-0.1.7.tar.gz

Download URL deep_sort_reid-0.1.7.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6cc68497b27358bf7c00974e8893039d0862780efa5388b1d473604a92b7143d
BLAKE2b-256 checksum
How to use checksums
7af3702225483c4f5eb3fddf59c984027c5d70cfcb78483950d171807d5c1b71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0

Release files / deep_sort_reid-0.1.7-py3-none-any.whl

Download URL deep_sort_reid-0.1.7-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17ac3f02fbac734d85b30647f55a653aa05feee4ee97f8d2c37d8fae89256c75
BLAKE2b-256 checksum
How to use checksums
581f3a1abb869aaf5d65b28e185ffc74922a9d99781dfd94def02feebfb7006a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page