Abstract
The ability to control a behavioral task or stimulate neural activity based on animal behavior in real-time is an important tool for experimental neuroscientists. Ideally, such tools are noninvasive, low-latency, and provide interfaces to trigger external hardware based on posture. Recent advances in pose estimation with deep learning allows researchers to train deep neural networks to accurately quantify a wide variety of animal behaviors. Here we provide a new DeepLabCut-Live! package that achieves low-latency real-time pose estimation (within 15 ms, >100 FPS), with an additional forward-prediction module that achieves zero-latency feedback, and a dynamic-cropping mode that allows for higher inference speeds. We also provide three options for using this tool with ease: (1) a stand-alone GUI (called DLC-Live! GUI), and integration into (2) Bonsai and (3) AutoPilot. Lastly, we benchmarked performance on a wide range of systems so that experimentalists can easily decide what hardware is required for their needs.
Introduction
In neuroscience and behavioral biology, "closing the loop"—stimulating a specific neural circuit or providing a reward the exact moment an animal performs a specific action—is a critical experimental goal. Traditionally, this required physical markers or was limited to simple sensors like infrared beams. While DeepLabCut (DLC) revolutionized the field by allowing markerless tracking via deep learning, it was primarily an offline tool due to the computational overhead of processing video frames. If software takes 50–100ms to detect a behavior, the neural window for causal intervention often closes. DeepLabCut-Live! (DLC-Live!) was developed to eliminate this lag and enable instantaneous feedback based on complex postures.
Methods
DeepLabCut-Live! is a suite of tools designed for high-speed inference and ecosystem integration. Key technical innovations include:
- Model Exporting: Trained DLC models are exported into a lightweight protocol buffer (
.pb) format, making them portable across programming environments like C# or Python without the overhead of the full training suite. - Dynamic Cropping: To reduce data processing, the software uses the animal's position in the previous frame to crop a small region of interest in the current frame. This can boost inference speeds by up to 75%.
- Forward-Prediction (Kalman Filter): To combat hardware delays from camera acquisition and GPU processing, a Kalman filter module uses current position, velocity, and acceleration to predict future posture, effectively achieving "zero-latency" feedback.
- Ecosystem Integration: The package includes a standalone GUI and native plugins for popular platforms like Bonsai and AutoPilot, facilitating ease of use in diverse laboratory setups.
Results
The system was validated across diverse scenarios, including mouse open-field tracking, dog rearing tasks, and high-speed mouse reaching/licking datasets. Benchmarking across a wide range of hardware—from high-end NVIDIA Titan RTX GPUs to affordable NVIDIA Jetson modules and standard CPUs—demonstrated robust performance.
- Latency and Throughput: On standard GPUs, the system achieves inference within 10–15 ms and can handle over 100 FPS in real-time. In offline batch mode, speeds can reach up to 2,500 FPS.
- Zero-Latency Feedback: In a dog rearing experiment, the Kalman filter allowed the system to trigger an LED with a median delay of -13 ms relative to the ideal detection time, successfully anticipating movement completion.
- Hardware Accessibility: By optimizing for embedded systems like the NVIDIA Jetson and standard CPUs, the authors have made high-end closed-loop experiments accessible to a broader range of research facilities.
Discussion and Conclusion
DeepLabCut-Live! demonstrates that software optimization, such as dynamic cropping and predictive modeling, is as critical as raw hardware power for real-time applications. While the Kalman filter is highly effective for smooth, rhythmic movements, it may encounter limitations during erratic behaviors. Future work will explore more sophisticated temporal models, such as LSTMs or GRUs, to improve prediction accuracy for complex tasks. Additionally, the researchers aim to extend these real-time capabilities to multi-animal tracking to facilitate the study of social interactions in closed-loop environments.
Summary updated