Skip to content

deeplabcut.pose_estimation_pytorch.config.data

Data configuration classes for DeepLabCut pose estimation models.

Classes:

Name Description
COCOLoaderConfig

Configuration for COCO Loader.

DLCLoaderConfig

Configuration for DeepLabCut Loader.

DataConfig

Complete data configuration.

DataTransformationConfig

Data transformation configuration.

DetectorDataConfig

Data configuration for object-detector training (no pose-only fields).

GenSamplingConfig

Configuration for CTD models.

COCOLoaderConfig

Bases: DLCBaseConfig

Configuration for COCO Loader.

Attributes:

Name Type Description
type Literal[COCOLoader]

Loader type identifier

Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class COCOLoaderConfig(DLCBaseConfig):
    """Configuration for COCO Loader.

    Attributes:
        type: Loader type identifier
    """

    type: Literal[DataLoaderType.COCOLoader]

DLCLoaderConfig

Bases: DLCBaseConfig

Configuration for DeepLabCut Loader.

Attributes:

Name Type Description
type Literal[DLCLoader]

Loader type identifier

config str | dict

Path to the DeepLabCut project config, or the project config itself

trainset_index NonNegativeInt

Index of the TrainingsetFraction for which to load data

shuffle NonNegativeInt

Index of the shuffle for which to load data

modelprefix str

The modelprefix for the shuffle

Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class DLCLoaderConfig(DLCBaseConfig):
    """Configuration for DeepLabCut Loader.

    Attributes:
        type: Loader type identifier
        config: Path to the DeepLabCut project config, or the project config itself
        trainset_index: Index of the TrainingsetFraction for which to load data
        shuffle: Index of the shuffle for which to load data
        modelprefix: The modelprefix for the shuffle
    """

    type: Literal[DataLoaderType.DLCLoader]
    config: str | dict
    trainset_index: NonNegativeInt = 0
    shuffle: NonNegativeInt = 0
    modelprefix: str = ""

DataConfig

Bases: DLCBaseConfig

Complete data configuration.

Attributes:

Name Type Description
bbox_margin NonNegativeInt

Bounding box margin for top-down models

colormode Literal['RGB']

Color mode for images (e.g., 'RGB', 'BGR')

gen_sampling GenSamplingConfig | None

Generation sampling configuration

inference DataTransformationConfig | None

Inference data configuration

train DataTransformationConfig | None

Training data configuration

loader DLCLoaderConfig | COCOLoaderConfig | None

Data loader configuration

Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class DataConfig(DLCBaseConfig):
    """Complete data configuration.

    Attributes:
        bbox_margin: Bounding box margin for top-down models
        colormode: Color mode for images (e.g., 'RGB', 'BGR')
        gen_sampling: Generation sampling configuration
        inference: Inference data configuration
        train: Training data configuration
        loader: Data loader configuration
    """

    bbox_margin: NonNegativeInt = 25
    colormode: Literal["RGB"] = "RGB"  # Docs state that it should never be changed to BGR
    gen_sampling: GenSamplingConfig | None = None
    inference: DataTransformationConfig | None = None
    train: DataTransformationConfig | None = None
    loader: DLCLoaderConfig | COCOLoaderConfig | None = Field(default=None, discriminator="type")

    @field_validator("train", "inference", mode="before")
    @classmethod
    def validate_transforms(cls, v):
        from deeplabcut.pose_estimation_pytorch.data import build_transforms

        try:
            build_transforms(v)
        except Exception as e:
            raise ValueError(f"Could not build transforms. Please check your config. Config: {v}; Error: {e}") from e
        return v

DataTransformationConfig

Bases: DLCBaseConfig

Data transformation configuration.

Attributes:

Name Type Description
resize dict | None

Resize transformation configuration

longest_max_size int | dict | None

Maximum size for longest edge

hflip bool | float | dict | None

Horizontal flip configuration

affine dict | None

Affine transformation configuration

random_bbox_transform dict | None

Random bbox transformation configuration

crop_sampling dict | None

Crop sampling configuration

hist_eq bool | dict | None

Whether to apply histogram equalization

motion_blur bool | dict | None

Whether to apply motion blur

covering bool | dict | None

Covering/CoarseDropout transformation configuration

elastic_transform bool | dict | None

Elastic transformation configuration

grayscale bool | dict | None

Grayscale transformation configuration

gaussian_noise bool | float | int | dict | None

Gaussian noise standard deviation

auto_padding dict | None

Auto padding configuration

normalize_images bool | dict | None

Whether to normalize images

scale_to_unit_range bool | dict | None

Whether to scale images to [0, 1] range

top_down_crop dict | None

Top-down crop configuration

collate dict | None

Collate function configuration

Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class DataTransformationConfig(DLCBaseConfig):
    """Data transformation configuration.

    Attributes:
        resize: Resize transformation configuration
        longest_max_size: Maximum size for longest edge
        hflip: Horizontal flip configuration
        affine: Affine transformation configuration
        random_bbox_transform: Random bbox transformation configuration
        crop_sampling: Crop sampling configuration
        hist_eq: Whether to apply histogram equalization
        motion_blur: Whether to apply motion blur
        covering: Covering/CoarseDropout transformation configuration
        elastic_transform: Elastic transformation configuration
        grayscale: Grayscale transformation configuration
        gaussian_noise: Gaussian noise standard deviation
        auto_padding: Auto padding configuration
        normalize_images: Whether to normalize images
        scale_to_unit_range: Whether to scale images to [0, 1] range
        top_down_crop: Top-down crop configuration
        collate: Collate function configuration
    """

    resize: dict | None = None
    longest_max_size: int | dict | None = None
    hflip: bool | float | dict | None = None
    affine: dict | None = None
    random_bbox_transform: dict | None = None
    crop_sampling: dict | None = None
    hist_eq: bool | dict | None = False
    motion_blur: bool | dict | None = False
    covering: bool | dict | None = None
    elastic_transform: bool | dict | None = None
    grayscale: bool | dict | None = None
    gaussian_noise: bool | float | int | dict | None = None
    auto_padding: dict | None = None
    normalize_images: bool | dict | None = True
    scale_to_unit_range: bool | dict | None = False
    top_down_crop: dict | None = None
    collate: dict | None = None

DetectorDataConfig

Bases: DLCBaseConfig

Data configuration for object-detector training (no pose-only fields).

Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class DetectorDataConfig(DLCBaseConfig):
    """Data configuration for object-detector training (no pose-only fields)."""

    colormode: Literal["RGB"] = "RGB"
    inference: DataTransformationConfig | None = None
    train: DataTransformationConfig | None = None

    @field_validator("train", "inference", mode="before")
    @classmethod
    def validate_transforms(cls, v):
        from deeplabcut.pose_estimation_pytorch.data import build_transforms

        try:
            build_transforms(v)
        except Exception as e:
            raise ValueError(f"Could not build transforms. Please check your config. Config: {v}; Error: {e}") from e
        return v

GenSamplingConfig

Bases: DLCBaseConfig

Configuration for CTD models.

Parameters:

Name Type Description Default

keypoint_sigmas

The sigma for each keypoint.

required

keypoints_symmetry

Indices of symmetric keypoints (e.g. left/right eye)

required

jitter_prob

The probability of applying jitter. Jitter error is defined as a small displacement from the GT keypoint.

required

swap_prob

The probability of applying a swap error. Swap error represents a confusion between the same or similar parts which belong to different persons.

required

inv_prob

The probability of applying an inversion error. Inversion error occurs when a pose estimation model is confused between semantically similar parts that belong to the same instance.

required

miss_prob

The probability of applying a miss error. Miss error represents a large displacement from the GT keypoint position.

required
Source code in deeplabcut/pose_estimation_pytorch/config/data.py
class GenSamplingConfig(DLCBaseConfig):
    """Configuration for CTD models.

    Args:
        keypoint_sigmas: The sigma for each keypoint.
        keypoints_symmetry: Indices of symmetric keypoints (e.g. left/right eye)
        jitter_prob: The probability of applying jitter. Jitter error is defined as
            a small displacement from the GT keypoint.
        swap_prob: The probability of applying a swap error. Swap error represents
            a confusion between the same or similar parts which belong to different
            persons.
        inv_prob: The probability of applying an inversion error. Inversion error
            occurs when a pose estimation model is confused between semantically
            similar parts that belong to the same instance.
        miss_prob: The probability of applying a miss error. Miss error represents a
            large displacement from the GT keypoint position.
    """

    model_config = ConfigDict(frozen=True)

    keypoint_sigmas: NonNegativeFloat | list[NonNegativeFloat] = 0.1
    keypoints_symmetry: list[tuple[int, int]] | None = None
    jitter_prob: Fraction = 0.16
    swap_prob: Fraction = 0.08
    inv_prob: Fraction = 0.03
    miss_prob: Fraction = 0.10