deeplabcut.pose_estimation_pytorch.apis.training
Functions:
| Name | Description |
|---|---|
train |
Builds a model from a configuration and fits it to a dataset. |
train_network |
Trains a network for a project. |
train
train(
loader: Loader,
run_config: dict,
task: Task,
device: str | None = "cpu",
gpus: list[int] | None = None,
logger_config: dict | None = None,
snapshot_path: str | Path | None = None,
transform: BaseCompose | None = None,
inference_transform: BaseCompose | None = None,
max_snapshots_to_keep: int | None = None,
load_head_weights: bool = True,
) -> None
Builds a model from a configuration and fits it to a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Loader
|
the loader containing the data to train on/validate with |
required |
|
dict
|
the model and run configuration |
required |
|
Task
|
the task to train the model for |
required |
|
str | None
|
the torch device to train on (such as "cpu", "cuda", "mps") |
'cpu'
|
|
list[int] | None
|
the list of GPU indices to use for multi-GPU training |
None
|
|
dict | None
|
the configuration of a logger to use |
None
|
|
str | Path | None
|
if continuing to train from a snapshot, the path containing the weights to load |
None
|
|
BaseCompose | None
|
if defined, overwrites the transform defined in the model config |
None
|
|
BaseCompose | None
|
if defined, overwrites the inference transform defined in the model config |
None
|
|
int | None
|
the maximum number of snapshots to store for each model |
None
|
|
bool
|
When |
True
|
Source code in deeplabcut/pose_estimation_pytorch/apis/training.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 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 | |
train_network
train_network(
config: str | Path,
shuffle: int = 1,
trainingsetindex: int = 0,
modelprefix: str = "",
device: str | None = None,
snapshot_path: str | Path | None = None,
detector_path: str | Path | None = None,
load_head_weights: bool = True,
batch_size: int | None = None,
epochs: int | None = None,
save_epochs: int | None = None,
detector_batch_size: int | None = None,
detector_epochs: int | None = None,
detector_save_epochs: int | None = None,
display_iters: int | None = None,
max_snapshots_to_keep: int | None = None,
pose_threshold: float | None = 0.1,
pytorch_cfg_updates: dict | None = None,
) -> None
Trains a network for a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
path to the yaml config file of the project |
required | |
|
index of the shuffle we want to train on |
required | |
|
training set index |
required | |
|
str
|
directory containing the deeplabcut configuration files to use to train the network (and where snapshots will be saved). By default, they are assumed to exist in the project folder. |
''
|
|
str | None
|
the torch device to train on (such as "cpu", "cuda", "mps") |
None
|
|
str | Path | None
|
if resuming training, the snapshot from which to resume |
None
|
|
str | Path | None
|
if resuming training of a top-down model, used to specify the detector snapshot from which to resume |
None
|
|
bool
|
if resuming training of a pose estimation model (either
through the |
True
|
|
int | None
|
overrides the batch size to train with |
None
|
|
int | None
|
overrides the maximum number of epochs to train the model for |
None
|
|
int | None
|
overrides the number of epochs between each snapshot save |
None
|
|
int | None
|
Only for top-down models. Overrides the batch size with which to train the detector. |
None
|
|
int | None
|
Only for top-down models. Overrides the maximum number of epochs to train the model for. Setting to 0 means the detector will not be trained. |
None
|
|
int | None
|
Only for top-down models. Overrides the number of epochs between each snapshot of the detector is saved. |
None
|
|
int | None
|
overrides the number of iterations between each log of the loss within an epoch |
None
|
|
int | None
|
the maximum number of snapshots to save for each model |
None
|
|
float | None
|
Used for memory-replay. Pseudo-predictions with confidence lower than this threshold are discarded for memory-replay |
0.1
|
|
dict | None
|
dict, optional, default = None. A dictionary of updates to the pytorch config. The keys are the dot-separated paths to the values to update in the config. For example, to update the gpus to run the training on, you can use: To see the full list - check the pytorch_cfg.yaml file in your project folder |
None
|
Source code in deeplabcut/pose_estimation_pytorch/apis/training.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |