Skip to content

deeplabcut.pose_estimation_pytorch.config.logger

Logger configuration classes for DeepLabCut training runs.

Classes:

Name Description
CSVLoggerConfig

Configuration for CSV logger.

LoggerConfig

Base configuration for all loggers.

WandbLoggerConfig

Configuration for Weights & Biases (wandb) logger.

CSVLoggerConfig

Bases: LoggerConfig

Configuration for CSV logger.

This logger saves training stats and metrics to a CSV file.

Attributes:

Name Type Description
type Literal[CSVLogger]

Logger type (should be 'CSVLogger')

train_folder str

The path of the folder containing training files.

log_filename str

The name of the file in which to store training stats

Source code in deeplabcut/pose_estimation_pytorch/config/logger.py
class CSVLoggerConfig(LoggerConfig):  #
    """Configuration for CSV logger.

    This logger saves training stats and metrics to a CSV file.

    Attributes:
        type: Logger type (should be 'CSVLogger')
        train_folder: The path of the folder containing training files.
        log_filename: The name of the file in which to store training stats
    """

    type: Literal[LoggerType.CSVLogger]
    train_folder: str = ""
    log_filename: str = "learning_stats.csv"

LoggerConfig

Bases: DLCBaseConfig

Base configuration for all loggers.

Attributes:

Name Type Description
type str

The type of logger to use (WandbLogger or CSVLogger)

Source code in deeplabcut/pose_estimation_pytorch/config/logger.py
class LoggerConfig(DLCBaseConfig):
    """Base configuration for all loggers.

    Attributes:
        type: The type of logger to use (WandbLogger or CSVLogger)
    """

    type: str

WandbLoggerConfig

Bases: LoggerConfig

Configuration for Weights & Biases (wandb) logger.

This logger tracks experiments and logs data to Weights & Biases. Refer to: https://docs.wandb.ai/guides for more information.

Notes

Different config versions might have top-level WandB options instead of wandb_kwargs. Unknown top-level fields are scooped into wandb_kwargs.

Attributes:

Name Type Description
type Literal[WandbLogger]

Logger type (should be 'WandbLogger')

project_name str

The name of the wandb project

run_name str

The name of the wandb run

image_log_interval int | None

How often train/test images are logged in epochs (if None, train/test inputs are never logged)

model dict | None

The model architecture to log

train_folder str | None

The path of the folder containing training files.

wandb_kwargs dict | None

Additional keyword arguments to pass to wandb.init

Methods:

Name Description
scoop_extra_wandb_kwargs

Move unknown top-level keys into wandb_kwargs

validate_wandb_kwargs

Reject nested keys that collide with reserved wandb.init options.

Source code in deeplabcut/pose_estimation_pytorch/config/logger.py
class WandbLoggerConfig(LoggerConfig):  #
    """Configuration for Weights & Biases (wandb) logger.

    This logger tracks experiments and logs data to Weights & Biases.
    Refer to: https://docs.wandb.ai/guides for more information.

    Notes:
        Different config versions might have top-level WandB options instead of
        wandb_kwargs. Unknown top-level fields are scooped into wandb_kwargs.

    Attributes:
        type: Logger type (should be 'WandbLogger')
        project_name: The name of the wandb project
        run_name: The name of the wandb run
        image_log_interval: How often train/test images are logged in epochs
            (if None, train/test inputs are never logged)
        model: The model architecture to log
        train_folder: The path of the folder containing training files.
        wandb_kwargs: Additional keyword arguments to pass to wandb.init
    """

    # These options are reserved since they are explicitly passed to wandb.init (from `project_name` and `run_name`)
    _FORBIDDEN_WANDB_KWARGS: ClassVar[frozenset[str]] = frozenset({"project", "name"})

    type: Literal[LoggerType.WandbLogger]
    project_name: str = "deeplabcut"
    run_name: str = "tmp"
    image_log_interval: int | None = None
    model: dict | None = None
    train_folder: str | None = None
    wandb_kwargs: dict | None = None

    @model_validator(mode="before")
    @classmethod
    def scoop_extra_wandb_kwargs(cls, data: Any) -> Any:
        """Move unknown top-level keys into ``wandb_kwargs``"""
        if not isinstance(data, dict):
            return data

        data = dict(data)
        known = set(cls.model_fields) | set(cls._alias_map())
        provided = set(data)
        extras = {key: data.pop(key) for key in provided - known}
        if not extras:
            return data

        nested = data.get("wandb_kwargs") or {}
        if not isinstance(nested, dict):
            raise ValueError("wandb_kwargs must be a dictionary when provided")

        overlap = set(extras) & set(nested)
        if overlap:
            raise ValueError(f"Duplicate wandb.init options at top-level and in wandb_kwargs: {sorted(overlap)}")

        data["wandb_kwargs"] = {**nested, **extras}
        return data

    @field_validator("wandb_kwargs")
    @classmethod
    def validate_wandb_kwargs(cls, v: dict | None) -> dict | None:
        """Reject nested keys that collide with reserved wandb.init options."""
        if not v:
            return v
        if set(v) & cls._FORBIDDEN_WANDB_KWARGS:
            raise ValueError(
                f"wandb_kwargs cannot include any of the reserved options: {sorted(cls._FORBIDDEN_WANDB_KWARGS)}"
            )
        return v

scoop_extra_wandb_kwargs classmethod

scoop_extra_wandb_kwargs(data: Any) -> Any

Move unknown top-level keys into wandb_kwargs

Source code in deeplabcut/pose_estimation_pytorch/config/logger.py
@model_validator(mode="before")
@classmethod
def scoop_extra_wandb_kwargs(cls, data: Any) -> Any:
    """Move unknown top-level keys into ``wandb_kwargs``"""
    if not isinstance(data, dict):
        return data

    data = dict(data)
    known = set(cls.model_fields) | set(cls._alias_map())
    provided = set(data)
    extras = {key: data.pop(key) for key in provided - known}
    if not extras:
        return data

    nested = data.get("wandb_kwargs") or {}
    if not isinstance(nested, dict):
        raise ValueError("wandb_kwargs must be a dictionary when provided")

    overlap = set(extras) & set(nested)
    if overlap:
        raise ValueError(f"Duplicate wandb.init options at top-level and in wandb_kwargs: {sorted(overlap)}")

    data["wandb_kwargs"] = {**nested, **extras}
    return data

validate_wandb_kwargs classmethod

validate_wandb_kwargs(v: dict | None) -> dict | None

Reject nested keys that collide with reserved wandb.init options.

Source code in deeplabcut/pose_estimation_pytorch/config/logger.py
@field_validator("wandb_kwargs")
@classmethod
def validate_wandb_kwargs(cls, v: dict | None) -> dict | None:
    """Reject nested keys that collide with reserved wandb.init options."""
    if not v:
        return v
    if set(v) & cls._FORBIDDEN_WANDB_KWARGS:
        raise ValueError(
            f"wandb_kwargs cannot include any of the reserved options: {sorted(cls._FORBIDDEN_WANDB_KWARGS)}"
        )
    return v