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. Args: cfg: The project's configuration.
(
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,
)
| 148 | |
| 149 | @staticmethod |
| 150 | def build( |
| 151 | cfg: dict, |
| 152 | super_animal: str, |
| 153 | model_name: str = "hrnet_w32", |
| 154 | detector_name: str = "fasterrcnn_resnet50_fpn_v2", |
| 155 | with_decoder: bool = False, |
| 156 | memory_replay: bool = False, |
| 157 | customized_pose_checkpoint: str | None = None, |
| 158 | customized_detector_checkpoint: str | None = None, |
| 159 | ) -> WeightInitialization: |
| 160 | """Builds a WeightInitialization for a project. |
| 161 | |
| 162 | `WeightInitialization.build` is deprecated and will be removed in a future |
| 163 | version of DeepLabCut. Please use `build_weight_init` from `deeplabcut.modelzoo` |
| 164 | instead. |
| 165 | |
| 166 | Args: |
| 167 | cfg: The project's configuration. |
| 168 | super_animal: The SuperAnimal model with which to initialize weights. |
| 169 | model_name: The name of the model architecture for which to load the weights |
| 170 | (defaults to "hrnet_w32" for backwards compatibility). |
| 171 | detector_name: The name of the detector architecture for which to load the |
| 172 | weights (defaults to "fasterrcnn_resnet50_fpn_v2" for backwards |
| 173 | compatibility). |
| 174 | with_decoder: Whether to load the decoder weights as well. If this is true, |
| 175 | a conversion table must be specified for the given SuperAnimal in the |
| 176 | project configuration file. See |
| 177 | ``deeplabcut.modelzoo.utils.create_conversion_table`` to create a |
| 178 | conversion table. |
| 179 | memory_replay: Only when ``with_decoder=True``. Whether to train the model |
| 180 | with memory replay, so that it predicts all SuperAnimal bodyparts. |
| 181 | customized_pose_checkpoint: A customized SuperAnimal pose checkpoint, as an |
| 182 | alternative to the Hugging Face one |
| 183 | customized_detector_checkpoint: A customized SuperAnimal detector |
| 184 | checkpoint, as an alternative to the Hugging Face one |
| 185 | |
| 186 | Returns: |
| 187 | The built WeightInitialization. |
| 188 | """ |
| 189 | from deeplabcut.modelzoo import build_weight_init |
| 190 | |
| 191 | deprecation_warning = ( |
| 192 | "The `WeightInitialization.build` is deprecated and will be removed in a " |
| 193 | "future version of DeepLabCut. Please use `build_weight_init` from " |
| 194 | "`deeplabcut.modelzoo` instead." |
| 195 | ) |
| 196 | warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2) |
| 197 | |
| 198 | return build_weight_init( |
| 199 | cfg, |
| 200 | super_animal, |
| 201 | model_name, |
| 202 | detector_name, |
| 203 | with_decoder, |
| 204 | memory_replay, |
| 205 | customized_pose_checkpoint, |
| 206 | customized_detector_checkpoint, |
| 207 | ) |