Skip to content

DeepLabCut PyTorch API Documentation

PyPI PyPI - Python Version License

This documentation is designed for maintainers, developers, and expert users who want to understand and extend the PyTorch backend of DeepLabCut 3.0+. It provides detailed information about the architecture, APIs, and practical examples for building and training state-of-the-art pose estimation models.

Overview

The deeplabcut.pose_estimation_pytorch package provides a complete framework for training and deploying deep learning models for pose estimation. The API is designed to be modular, flexible, and extensible, allowing developers to easily add new models, customize training pipelines, and integrate with existing workflows.

Core Components

The PyTorch DeepLabCut codebase is organized into four main components:

High-Level APIs

The deeplabcut.pose_estimation_pytorch.apis module contains high-level methods for training, evaluation, and inference. These methods work seamlessly with DeepLabCut projects but can also be used independently for maximum flexibility.

Key functions include:

Models

The deeplabcut.pose_estimation_pytorch.models package provides state-of-the-art pose estimation architectures including DLCRNet, HRNet, DEKR, BUCTD, and RTMPose. Models are built from modular components:

Object detection models for top-down pose estimation are available in deeplabcut.pose_estimation_pytorch.models.detectors.

You can check available models programmatically:

import deeplabcut.pose_estimation_pytorch as dlc_torch

# List available pose estimation models
print(dlc_torch.available_models())

# List available object detection models
print(dlc_torch.available_detectors())

Data Loading

The deeplabcut.pose_estimation_pytorch.data package handles dataset creation, train/test splitting, and data augmentation. Two main data loaders are provided:

The PoseDataset class extends torch.utils.data.Dataset to provide tensor-based datasets for training and evaluation.

Training and Inference Runners

The deeplabcut.pose_estimation_pytorch.runners module provides classes for model training and inference: