deeplabcut.pose_estimation_pytorch.config.ctd_conditions
Typed configuration for CTD (Conditional Top-Down) model conditions.
Three subclasses cover the supported input forms:
ConditionsFileConfig— pre-computed predictions from a file (evaluation only)ConditionsModelConfig— fully resolved BU model (config path + snapshot path) for liveanalyze_*inferenceConditionsShuffleConfig— unresolved shuffle shorthand. At runtime: - live inference →ConditionsModelConfig.resolve_from_conditions()- evaluation →CondFromFile(config=..., shuffle=..., ...)
Use ConditionsConfig.build() to normalise any raw input (str, Path, dict) into one
of these types. build() is pure (no filesystem access) and safe to call from Pydantic
validators. Resolution that requires the filesystem must go through
ConditionsModelConfig.resolve_from_conditions().
Context rules for inference.conditions / ctd_conditions:
- Evaluation accepts File and Shuffle (loads pre-computed BU predictions).
- Live analyze (
analyze_images/analyze_videos) accepts Shuffle and Model only. A predictions file path in the YAML is evaluation-only and is rejected byresolve_from_conditions.
Classes:
| Name | Description |
|---|---|
ConditionsConfig |
Base class for CTD conditions configuration. |
ConditionsFileConfig |
Conditions loaded from a pre-computed predictions file (.h5, .json, .pickle). |
ConditionsModelConfig |
Resolved config for a BU model (i.e. a snapshot ref for live inference). |
ConditionsShuffleConfig |
Unresolved shuffle shorthand for CTD conditions. |
ConditionsConfig
Bases: DLCBaseConfig
Base class for CTD conditions configuration.
Use ConditionsConfig.build() to normalise any raw input into a typed subclass.
Subclasses
ConditionsFileConfig— pre-computed predictions file (evaluation only)ConditionsModelConfig— resolved BU model (config + snapshot paths)ConditionsShuffleConfig— unresolved shuffle shorthand (resolve to Model for live inference, or toCondFromFilefor evaluation)
Methods:
| Name | Description |
|---|---|
build |
Normalise any raw input into a typed conditions config. |
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
build
classmethod
build(
v: str | Path | dict | ConditionsConfig | None,
) -> ConditionsFileConfig | ConditionsModelConfig | ConditionsShuffleConfig | None
Normalise any raw input into a typed conditions config.
This method is pure — it never touches the filesystem. For shuffle
shorthand inputs it returns a ConditionsShuffleConfig (unresolved).
To obtain a fully resolved ConditionsModelConfig call
ConditionsModelConfig.resolve_from_conditions() at the point where
the project config is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path | dict | ConditionsConfig | None
|
Raw input. Accepted forms:
- |
required |
Returns:
| Type | Description |
|---|---|
ConditionsFileConfig | ConditionsModelConfig | ConditionsShuffleConfig | None
|
A typed |
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
ConditionsFileConfig
Bases: ConditionsConfig
Conditions loaded from a pre-computed predictions file (.h5, .json, .pickle).
File-based conditions are for evaluation only (load_conditions_for_evaluation
/ CondFromFile). They cannot be used for live analyze_images /
analyze_videos inference — use a shuffle or ConditionsModelConfig instead.
Attributes:
| Name | Type | Description |
|---|---|---|
filepath |
Path
|
Path to the predictions file. |
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
ConditionsModelConfig
Bases: ConditionsConfig
Resolved config for a BU model (i.e. a snapshot ref for live inference).
Attributes:
| Name | Type | Description |
|---|---|---|
config_path |
Path
|
Path to the BU model's |
snapshot_path |
Path
|
Path to the BU snapshot file. |
scorer |
str | None
|
Scorer name for the BU model. Used to look for pre-computed conditions files on disk before running the model. |
Methods:
| Name | Description |
|---|---|
from_shuffle |
Resolve a DLC BU shuffle to its model config and snapshot paths. |
resolve_from_conditions |
Resolve conditions input to a |
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
from_shuffle
classmethod
from_shuffle(
config: str | Path,
shuffle: int,
trainset_index: int = 0,
modelprefix: str = "",
snapshot: str | None = None,
snapshot_index: int | None = None,
) -> ConditionsModelConfig
Resolve a DLC BU shuffle to its model config and snapshot paths.
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
resolve_from_conditions
classmethod
resolve_from_conditions(
conditions: dict | ConditionsShuffleConfig | ConditionsModelConfig, config: str | Path | None = None
) -> ConditionsModelConfig
Resolve conditions input to a ConditionsModelConfig for live BUCTD
inference (analyze_images / analyze_videos).
Call this in runtime code. It may touch the filesystem when resolving a
ConditionsShuffleConfig to a ConditionsModelConfig.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict | ConditionsShuffleConfig | ConditionsModelConfig
|
A dict, |
required |
|
str | Path | None
|
Project |
None
|
Returns:
| Type | Description |
|---|---|
ConditionsModelConfig
|
A resolved |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
Source code in deeplabcut/pose_estimation_pytorch/config/ctd_conditions.py
ConditionsShuffleConfig
Bases: ConditionsConfig
Unresolved shuffle shorthand for CTD conditions.
Stores shuffle parameters without touching the filesystem. Resolve at runtime when the project config is available:
- Live BU inference:
ConditionsModelConfig.resolve_from_conditions() - Evaluation predictions file:
CondFromFile(config=..., shuffle=..., ...)
Attributes:
| Name | Type | Description |
|---|---|---|
shuffle |
int
|
The index of the BU shuffle to use for conditions. |
config |
Path | None
|
Path to the DLC project |
trainset_index |
int
|
The TrainingsetFraction index. |
modelprefix |
str
|
The model prefix for the shuffle. |
snapshot |
str | None
|
Specific snapshot filename to use. Takes priority over
|
snapshot_index |
int | None
|
Index of the snapshot to use (default: -1, last). |