deeplabcut.core.weight_init
Classes to configure how to initialize model weights.
Classes:
| Name | Description |
|---|---|
WeightInitialization |
Configures weights initialization when transfer learning or fine-tuning models. |
WeightInitialization
dataclass
Configures weights initialization when transfer learning or fine-tuning models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Path
|
The path to the snapshot used to initialize pose model weights when training a model. |
required |
|
Path | None
|
The path to the snapshot used to initialize detector weights when training a model. |
None
|
|
str | None
|
Optionally, the dataset on which the snapshots were trained. Required when fine-tuning SuperAnimal models. |
None
|
|
bool
|
Whether to load the decoder weights as well. |
False
|
|
bool
|
Only when |
False
|
|
ndarray | None
|
The mapping from SuperAnimal (or other project, on which the
weights were trained) to project bodyparts. Required when
|
None
|
|
list[str] | None
|
Optionally, the name of each bodypart entry in the conversion array. |
None
|
Methods:
| Name | Description |
|---|---|
build |
Builds a WeightInitialization for a project. |
from_dict_legacy |
Deals with weight initialization that were created before 3.0.0rc5. |
to_dict |
Returns: the weight initialization as a dict |
Source code in deeplabcut/core/weight_init.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 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 198 199 200 201 202 203 204 205 206 207 | |
build
staticmethod
build(
cfg: dict,
super_animal: str,
model_name: str = "hrnet_w32",
detector_name: str = "fasterrcnn_resnet50_fpn_v2",
with_decoder: bool = False,
memory_replay: bool = False,
customized_pose_checkpoint: str | None = None,
customized_detector_checkpoint: str | None = None,
) -> WeightInitialization
Builds a WeightInitialization for a project.
WeightInitialization.build is deprecated and will be removed in a future
version of DeepLabCut. Please use build_weight_init from deeplabcut.modelzoo
instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
The project's configuration. |
required |
|
str
|
The SuperAnimal model with which to initialize weights. |
required |
|
str
|
The name of the model architecture for which to load the weights (defaults to "hrnet_w32" for backwards compatibility). |
'hrnet_w32'
|
|
str
|
The name of the detector architecture for which to load the weights (defaults to "fasterrcnn_resnet50_fpn_v2" for backwards compatibility). |
'fasterrcnn_resnet50_fpn_v2'
|
|
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 | None
|
A customized SuperAnimal pose checkpoint, as an alternative to the Hugging Face one |
None
|
|
str | None
|
A customized SuperAnimal detector checkpoint, as an alternative to the Hugging Face one |
None
|
Returns:
| Type | Description |
|---|---|
WeightInitialization
|
The built WeightInitialization. |
Source code in deeplabcut/core/weight_init.py
from_dict_legacy
staticmethod
Deals with weight initialization that were created before 3.0.0rc5.
Source code in deeplabcut/core/weight_init.py
to_dict
Returns: the weight initialization as a dict