deeplabcut.modelzoo.weight_initialization
Functions to build weight initialization parameters for SuperAnimal models.
Functions:
| Name | Description |
|---|---|
build_weight_init |
Builds the WeightInitialization from a SuperAnimal model for a project. |
build_weight_init
build_weight_init(
cfg: dict | str | Path,
super_animal: str,
model_name: str,
detector_name: str | None,
with_decoder: bool = False,
memory_replay: bool = False,
customized_pose_checkpoint: str | Path | None = None,
customized_detector_checkpoint: str | Path | None = None,
) -> WeightInitialization
Builds the WeightInitialization from a SuperAnimal model for a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict | str | Path
|
The project's configuration, or the path to the project configuration file. |
required |
|
str
|
The SuperAnimal model with which to initialize weights. |
required |
|
str
|
The type of the model architecture for which to load the weights. |
required |
|
str | None
|
The type of detector architecture for which to load the weights. |
required |
|
bool
|
Whether to load the decoder weights as well. If this is true,
a conversion table must be specified for the given SuperAnimal in the
project configuration file. See
|
False
|
|
bool
|
Only when |
False
|
|
str | Path | None
|
A customized SuperAnimal pose checkpoint, as an alternative to the Hugging Face one |
None
|
|
str | Path | None
|
A customized SuperAnimal detector checkpoint, as an alternative to the Hugging Face one |
None
|
To build a WeightInitialization instance for a project using the conversion table specified in the project configuration file, use:
```
from pathlib import Path
from deeplabcut.utils.auxiliaryfunctions import read_config
from deeplabcut.modelzoo import build_weight_init
project_cfg = read_config("/path/to/my/project/config.yaml")
super_animal = "superanimal_quadruped"
weight_init = build_weight_init(
cfg=project_cfg,
super_animal="superanimal_quadruped",
model_name="hrnet_w32",
detector_name="fasterrcnn_resnet50_fpn_v2",
with_decoder=True,
memory_replay=False,
)
```
Returns:
| Type | Description |
|---|---|
WeightInitialization
|
The built WeightInitialization. |