Machine learning framework for building object trackers and similarity search engines

Overview

Similari

Rust Rust

Similari is a framework that helps build sophisticated tracking systems. The most frequently met operations that can be efficiently implemented with Similari - collecting of observable object features, looking for similar objects, and merging them into tracks based on features and attributes.

With Similari one can develop highly efficient parallelized SORT, DeepSORT, and other sophisticated single observer (e.g. Cam) or multi-observer tracking engines.

Introduction

The primary purpose of Similari is to provide means to build sophisticated in-memory object tracking engines.

The framework helps to build various kinds of tracking or similarity search engines - the simplest one that holds vector features and allows comparing new vectors against the ones kept in the database. More sophisticated engines operate over tracks - a series of observations for the same feature collected during the lifecycle. Such systems are often used in video processing or other systems where the observer receives fuzzy or changing observation results.

Applicability Notes

Although Similari allows building various similarity engines, there are competitive tools that sometime (or often) may be more desirable. The section will explain where it is applicable and what alternatives exist.

Similari fits best for the tasks where objects are described by multiple observations for a certain feature class, not a single feature vector. Also, their behavior is dynamic - you remove them from the index or modify them as often as add new ones. This is a very important point - it is less efficient than tools that work with growing or static object spaces.

  • Fit: track the person across the room: person ReID, age/gender, and face features are collected multiple times during the tracking and used to merge tracks or provide aggregated results at the end of the track;
  • Not fit: plagiarism database, when a single document is described by a number (or just one) constant ReID vectors, documents are added but not removed. The task is to find the top X most similar documents to a checked.

If your task looks like Not fit, can use Similari, but you're probably looking for HNSW or NMS implementations:

Objects in Similari index support following features:

  • Track lifecycle - the object is represented by its lifecycle (track) - it appears, evolves, and disappears. During its lifetime object evolves according to its behavioral properties (attributes, and feature observations).
  • Feature Observation - Similari assumes that an object is observed by an observer entity that collects its features multiple times. Those features are presented by vectors of float numbers and observation attributes. When the observation happened, the track is updated with gathered features. Future observations are used to find similar tracks in the index and merge them.
  • Track Attributes - Arbitrary attributes describe additional track properties aside from feature observations. Attributes is crucial part when you are comparing objects in the wild, because there may be attributes disposition when objects are incompatible, like animal_type that prohibits you from comparing dogs and cats between each other. Another popular use of attributes is a spatial or temporal characteristic of an object, e.g. objects that are situated at distant locations at the same time cannot be compared. Attributes in Similari are dynamic and evolve upon every feature observation addition and when objects are merged. They are used in both distance calculations and compatibility guessing (which decreases compute space by skipping incompatible objects).

If you are planning to use Similari to search in a huge index, consider object attributes to decrease the lookup space. If the attributes of the two tracks are not compatible, their distance calculations are skipped.

Performance

To keep the calculations performant the framework uses:

Parallel computations are implemented with index sharding and parallel computations based on a dedicated thread workers pool.

The vector operations performance depends a lot on the optimization level defined for the build. On low or default optimization levels Rust may not use f32 vectorization, so when running benchmarks take care of proper optimization levels configured.

Rust optimizations

Use RUSTFLAGS="-C target-cpu=native" to enable all cpu features like AVX, AVX2, etc. It is beneficial to ultraviolet.

Alternatively you can add build instructions to .cargo/config:

[build]
rustflags = "-C target-cpu=native"

Take a look at benchmarks for numbers.

Numbers

IoU tracking benchmark for N simultaneously observed objects run on 4 cores of Intel(R) Core(TM) i5-7440HQ CPU @ 2.80GHz. The benchmark doesn't use heuristics that separate the observed objects based on object distances.

The benchmark is located at benches/iou_tracker.rs.

10 objects   :      261,184 ns/iter (+/- 170,940)      [3800 FPS]
100 objects  :    1,440,733 ns/iter (+/- 361,937)      [ 694 FPS]
500 objects  :  17,705,508 ns/iter (+/- 5,622,983)     [  57 FPS]
1000 objects :  58,834,824 ns/iter (+/- 12,626,173)    [  17 FPS]

Feature (256 @ f32) tracking benchmark for N simultaneously observed objects run on 4 cores of Intel(R) Core(TM) i5-7440HQ CPU @ 2.80GHz. The benchmark doesn't use heuristics that separate the observed objects based on object distances.

The benchmark located at benches/feature_tracker.rs.

10 objects:       101,465 ns/iter (+/- 10,056)         [9900 FPS]
100 objects:    4,020,673 ns/iter (+/- 877,444)        [ 250 FPS]
500 objects:   61,716,729 ns/iter (+/- 11,215,929)     [  16 FPS]
1000 objects: 235,187,877 ns/iter (+/- 89,734,978)     [   4 FPS]

Manuals and Articles

Collected articles about Similari:

  • IoU object tracker example at Medium
  • Re-ID object tracker example at Medium

Usage Examples

Take a look at samples in the repo:

You might also like...
The Hacker's Machine Learning Engine

Juice This is the workspace project for juice - machine learning frameworks for hackers coaster - underlying math abstraction coaster-nn coaster-blas

Machine learning in Rust.

Rustml Rustml is a library for doing machine learning in Rust. The documentation of the project with a descprition of the modules can be found here. F

Rust based Cross-GPU Machine Learning

HAL : Hyper Adaptive Learning Rust based Cross-GPU Machine Learning. Why Rust? This project is for those that miss strongly typed compiled languages.

Machine Learning Library for Rust

autograph Machine Learning Library for Rust undergoing maintenance Features Portable accelerated compute Run SPIR-V shaders on GPU's that support Vulk

Fwumious Wabbit, fast on-line machine learning toolkit written in Rust
Fwumious Wabbit, fast on-line machine learning toolkit written in Rust

Fwumious Wabbit is a very fast machine learning tool built with Rust inspired by and partially compatible with Vowpal Wabbit (much love! read more abo

Example of Rust API for Machine Learning

rust-machine-learning-api-example Example of Rust API for Machine Learning API example that uses resnet224 to infer images received in base64 and retu

convolutions-rs is a crate that provides a fast, well-tested convolutions library for machine learning

convolutions-rs convolutions-rs is a crate that provides a fast, well-tested convolutions library for machine learning written entirely in Rust with m

High-level non-blocking Deno bindings to the rust-bert machine learning crate.

bertml High-level non-blocking Deno bindings to the rust-bert machine learning crate. Guide Introduction The ModelManager class manages the FFI bindin

Machine learning Neural Network in Rust

vinyana vinyana - stands for mind in pali language. Goal To implement a simple Neural Network Library in order to understand the maths behind it. This

Comments
  • Build without Python support?

    Build without Python support?

    I have the same issue as https://github.com/insight-platform/Similari/issues/67 with roughly the same configuration. Because my project is made for multiple hosts configurations, adding a dependency on Python through PyO3 without a very good reason is almost a deal breaker.

    Is there any plans to make the Python bindings an optional feature?

    opened by higmo 5
  • Medium example won't build. Pyo3 issue?

    Medium example won't build. Pyo3 issue?

    Following your example from https://medium.com/@kudryavtsev_ia/high-performance-sort-tracker-in-rust-9a1dd18c259c

    Under MacOS 12.5 with rust 1.62.1, the example won't build with targets x86_64 and arm64 as there seems to be an issue with Pyo3.

    See the attached build log. build.log

    opened by skahl 3
  • Fix build on macOS

    Fix build on macOS

    Add a build.rs to set the appropriate build flags for macOS, following the recommendations here: https://pyo3.rs/v0.16.4/building_and_distribution.html#macos

    Relates to https://github.com/insight-platform/Similari/issues/67.

    opened by higmo 2
  • Avoid Visual Feature Using and Collecting for Overlapped Boxes

    Avoid Visual Feature Using and Collecting for Overlapped Boxes

    When the boxes are heavily overlapped the features tend to be of a poor quality. This request introduces the requirement to avoid using such features in comparisons or collecting them to the track for future use.

    opened by bwsw 1
Releases(v0.22.9)
Owner
In-Sight
In-Sight Platform OSS components
In-Sight
Allow DataFusion to resolve queries across remote query engines while pushing down as much compute as possible down.

DataFusion Federation The goal of this repo is to allow DataFusion to resolve queries across remote query engines while pushing down as much compute a

null 15 Mar 11, 2024
A Rust machine learning framework.

Linfa linfa (Italian) / sap (English): The vital circulating fluid of a plant. linfa aims to provide a comprehensive toolkit to build Machine Learning

Rust-ML 2.2k Jan 2, 2023
Xaynet represents an agnostic Federated Machine Learning framework to build privacy-preserving AI applications.

xaynet Xaynet: Train on the Edge with Federated Learning Want a framework that supports federated learning on the edge, in desktop browsers, integrate

XayNet 196 Dec 22, 2022
Tangram is an automated machine learning framework designed for programmers.

Tangram Tangram is an automated machine learning framework designed for programmers. Run tangram train to train a model from a CSV file on the command

Tangram 1.4k Dec 30, 2022
A Machine Learning Framework for High Performance written in Rust

polarlight polarlight is a machine learning framework for high performance written in Rust. Key Features TBA Quick Start TBA How To Contribute Contrib

Chris Ohk 25 Aug 23, 2022
A Framework for Production-Ready Continuous Machine Learning

CML "Domain generalization is dead, Continuous Machine Learning lives forever." —— an iKun CML is a framework for production-ready continuous machine

Yu Sun 3 Aug 1, 2023
[WIP] An experimental Java-like language and it's virtual machine, for learning Java and JVM.

Sky VM An experimental Java-like language and it's virtual machine, for learning Java and JVM. Dependencies Rust (rust-lang/rust) 2021 Edition, dual-l

Kk Shinkai 2 Jan 3, 2022
Tangram - makes it easy for programmers to train, deploy, and monitor machine learning models.

Tangram is the all-in-one machine learning toolkit for programmers. Train a model from a CSV file on the command line. Make predictions from Elixir, G

Tangram 1.3k May 3, 2022
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Machine learning crate for Rust

rustlearn A machine learning package for Rust. For full usage details, see the API documentation. Introduction This crate contains reasonably effectiv

Maciej Kula 547 Dec 28, 2022