Siamese Network-Based All-Purpose-Tracker, a Model-Free Deep Learning Tool for Animal Behavioral Tracking

Lihui Su, Wenyao Wang, Kaiwen Sheng, Xiaofei Liu, Kai Du, Yonghong Tian, Лей МаFrontiers in Behavioral Neuroscience 2022

Abstract

Accurate tracking is the basis of behavioral analysis, an important research method in neuroscience and many other fields. However, the currently available tracking methods have limitations. Traditional computer vision methods have problems in complex environments, and deep learning methods are hard to be applied universally due to the requirement of laborious annotations. To address the trade-off between accuracy and universality, we developed an easy-to-use tracking tool, Siamese Network-based All-Purpose Tracker (SNAP-Tracker), a model-free tracking software built on the Siamese network. The pretrained Siamese network offers SNAP-Tracker a remarkable feature extraction ability to keep tracking accuracy, and the model-free design makes it usable directly before laborious annotations and network refinement. SNAP-Tracker provides a "tracking with detection" mode to track longer videos with an additional detection module. We demonstrate the stability of SNAP-Tracker through different experimental conditions and different tracking tasks. In short, SNAP-Tracker provides a general solution to behavioral tracking without compromising accuracy.

Introduction

In behavioral neuroscience, the ability to precisely track an animal's movement is the fundamental prerequisite for understanding the relationship between brain activity and behavior. While traditional computer vision techniques, such as background subtraction, offer high processing speeds, they frequently fail in "messy" or dynamic environments where lighting changes or backgrounds are complex. Conversely, modern deep learning tools like DeepLabCut (DLC) or LEAP provide high accuracy but impose a significant "annotation tax," requiring researchers to manually label hundreds or thousands of frames to train a specific model for every new experimental setup.

SNAP-Tracker (Siamese Network-based All-Purpose Tracker) was developed to resolve this trade-off between accuracy and universality. By utilizing a "model-free" approach, SNAP-Tracker allows researchers to begin tracking diverse species in complex environments immediately after labeling just a single frame, eliminating the need for the massive manual datasets typically required by deep learning frameworks.

Methods

The Siamese Network Architecture

The core of SNAP-Tracker is a Siamese Network. Unlike standard neural networks that attempt to classify an object (e.g., identifying a "mouse paw"), a Siamese network consists of two identical subnetworks that learn to compare two images to determine their similarity.

In the SNAP-Tracker workflow, a user draws a bounding box around the target in the first frame, which serves as the "template." The network then searches subsequent frames for the area that most closely matches the features of that template. This process is supported by a pretrained backbone (such as AlexNet or ResNet-50) trained on massive general datasets like ImageNet. This allows the system to recognize shapes and textures without needing to be specifically "taught" what a particular animal looks like.

Tracking with Detection (TWD)

To handle long-duration videos where a tracker might "drift" or lose the target, the authors implemented a "Tracking with Detection" (TWD) mode. This involves a Faster R-CNN detection module that is trained on the fly using the initial successful tracking results. If the tracker’s confidence score drops below a certain threshold, the detector re-localizes the target. Additionally, technical layers like ROI-Align and distractor learning help the network ignore background noise and focus strictly on the features within the bounding box.

Experimental Validation

A mouse being tracked in a freely running environment with a complex grid floor.

The researchers validated SNAP-Tracker across a wide variety of biological subjects and experimental conditions:

  • Mouse Freely Running: A primary dataset involving varying lighting, floor colors, and head directions.
  • Zebrafish: Tracking an individual within a social group.
  • Specialized Tasks: Measuring mouse pupil dilation, chimpanzee finger movements during keyboard tasks, and complex courtship displays in Peacock Spiders and Blue-capped Cordon-bleus.
Example of the tracker maintaining focus on a subject in a low-contrast environment.

Key Results

Accuracy in "Open Conditions"

Model-based tools often fail when environmental conditions change slightly (e.g., a shift in camera angle or lighting) because the new data falls outside their training distribution. Because SNAP-Tracker compares frames locally and relies on similarity rather than fixed object recognition, it proved much more resilient to these "open condition" changes than DLC or LEAP.

Efficiency and Labor Reduction

In the TWD mode, SNAP-Tracker achieved accuracy comparable to DLC while requiring two orders of magnitude fewer manual labels. Across five diverse tracking tasks, the average human correction required was only 0.9% ± 1.7% of the total frames. This means a tiny amount of human intervention—correcting a single frame when the tracker drifts—can "rescue" the track for thousands of subsequent frames.

Discussion and Limitations

SNAP-Tracker represents a significant shift toward "model-free" behavioral analysis. Its primary advantage lies in its immediate usability across species and its robustness in changing environments. However, limitations remain. Like most tracking systems, SNAP-Tracker can struggle with total, long-term occlusions where the target is completely hidden. Furthermore, while the tool is packaged in a user-friendly GUI, users may still need to perform minor trial-and-error adjustments to hyperparameters, such as the confidence threshold, depending on video quality.

Future iterations of the tool aim to improve handling for targets that leave and re-enter the frame entirely and to automate hyperparameter selection for different species and environments.

Summary updated

BibTeX
@inproceedings{su2022siamese,
  author = {Lihui Su and Wenyao Wang and Kaiwen Sheng and Xiaofei Liu and Kai Du and Yonghong Tian and Лей Ма},
  title = {{Siamese Network-Based All-Purpose-Tracker, a Model-Free Deep Learning Tool for Animal Behavioral Tracking}},
  booktitle = {Frontiers in Behavioral Neuroscience},
  year = {2022},
  doi = {10.3389/fnbeh.2022.759943},
}
Figure