deeplabcut.pose_estimation_pytorch.config.utils
Util functions to create pytorch pose configuration files.
Functions:
| Name | Description |
|---|---|
available_detectors |
Returns: all the possible detectors that can be used |
available_models |
Returns: the possible variants of models that can be used |
get_config_folder_path |
Returns: the Path to the folder containing the "configs" for DeepLabCut 3.0 |
is_model_cond_top_down |
Checks whether a given net_type is conditional top-down or not. |
is_model_top_down |
Checks whenever a given net_type is top-down or not. |
load_backbones |
Args: |
load_base_config |
Returns: the base configuration for all PyTorch DeepLabCut models |
load_detectors |
Args: |
replace_default_values |
Replaces placeholder values in a model configuration with their actual values. |
update_config |
Updates items in the configuration file. |
update_config_by_dotpath |
Updates items in the configuration file using dot notation for nested keys. |
available_detectors
available_models
Returns: the possible variants of models that can be used
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
get_config_folder_path
Returns: the Path to the folder containing the "configs" for DeepLabCut 3.0
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
is_model_cond_top_down
Checks whether a given net_type is conditional top-down or not.
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
is_model_top_down
Checks whenever a given net_type is top-down or not.
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
load_backbones
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
the Path to the folder containing the "configs" for PyTorch DeepLabCut |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
all backbones with default configurations that can be used |
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
load_base_config
Returns: the base configuration for all PyTorch DeepLabCut models
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
load_detectors
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
the Path to the folder containing the "configs" for PyTorch DeepLabCut |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
all detectors that are available |
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
replace_default_values
replace_default_values(
config: dict | list,
num_bodyparts: int | None = None,
num_individuals: int | None = None,
backbone_output_channels: int | None = None,
**kwargs
) -> dict
Replaces placeholder values in a model configuration with their actual values.
This method allows to create template PyTorch configurations for models with values such as "num_bodyparts", which are replaced with the number of bodyparts for a project when making its Pytorch configuration.
This code can also do some basic arithmetic. You can write "num_bodyparts x 2" (or any factor other than 2) for location refinement channels, and the number of channels will be twice the number of bodyparts. You can write "backbone_output_channels // 2" for the number of channels in a layer, and it will be half the number of channels output by the backbone. You can write "num_bodyparts + 1" (such as for DEKR heatmaps, where a "center" bodypart is added).
The three base placeholder values that can be computed are "num_bodyparts", "num_individuals" and "backbone_output_channels". You can add more through the keyword arguments (such as "paf_graph": list[tuple[int, int]] or "paf_edges_to_keep": list[int] for DLCRNet models).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict | list
|
the configuration in which to replace default values |
required |
|
int | None
|
the number of bodyparts |
None
|
|
int | None
|
the number of individuals |
None
|
|
int | None
|
the number of backbone output channels |
None
|
|
other placeholder values to fill in |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
the configuration with placeholder values replaced |
Raises:
| Type | Description |
|---|---|
ValueError
|
if there is a placeholder value who's "updated" value was not given to the method |
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
update_config
Updates items in the configuration file.
The configuration dict should only be composed of primitive Python types
(dict, list and values). This is the case when reading the file using
read_config_as_dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
the configuration dict to update |
required |
|
dict
|
the updates to make to the configuration dict |
required |
|
bool
|
whether to copy the original dict before updating it |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
the updated dictionary |
Source code in deeplabcut/pose_estimation_pytorch/config/utils.py
update_config_by_dotpath
Updates items in the configuration file using dot notation for nested keys.
The configuration dict should only be composed of primitive Python types
(dict, list and values). This is the case when reading the file using
read_config_as_dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
the configuration dict to update |
required |
|
dict
|
single-level dict with dot notation keys indicating nested paths e.g. {"device": "cuda", "runner.gpus": [0,1]} |
required |
|
bool
|
whether to copy the original dict before updating it |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
the updated dictionary |