model_config
sleap_nn.config.model_config
¶
Serializable configuration classes for specifying all model config parameters.
These configuration classes are intended to specify all the parameters required to initialize the model config.
Classes:
Name | Description |
---|---|
BackboneConfig |
Configurations related to model backbone configuration. |
BottomUpConfMapsConfig |
Bottomup configuration map. |
BottomUpConfig |
bottomup head_config. |
BottomUpMultiClassConfig |
Head config for BottomUp Id models. |
CenteredInstanceConfMapsConfig |
Centered Instance configuration map. |
CenteredInstanceConfig |
centered_instance head_config. |
CentroidConfMapsConfig |
Centroid configuration map. |
CentroidConfig |
centroid head_config. |
ClassMapConfig |
Class map head config. |
ClassVectorsConfig |
Configurations for class vectors heads. |
ConvNextBaseConfig |
Convnext configuration for backbone. |
ConvNextConfig |
Convnext configuration for backbone. |
ConvNextLargeConfig |
Convnext configuration for backbone. |
ConvNextSmallConfig |
Convnext configuration for backbone. |
HeadConfig |
Configurations related to the model output head type. |
ModelConfig |
Configurations related to model architecture. |
PAFConfig |
PAF configuration map. |
SingleInstanceConfMapsConfig |
Single Instance configuration map. |
SingleInstanceConfig |
single instance head_config. |
SwinTBaseConfig |
SwinT configuration for backbone. |
SwinTConfig |
SwinT configuration (tiny) for backbone. |
SwinTSmallConfig |
SwinT configuration (small) for backbone. |
TopDownCenteredInstanceMultiClassConfig |
Head config for TopDown centered instance ID models. |
UNetConfig |
UNet config for backbone. |
UNetLargeRFConfig |
UNet config for backbone with large receptive field. |
UNetMediumRFConfig |
UNet config for backbone with medium receptive field. |
Functions:
Name | Description |
---|---|
model_mapper |
Map the legacy model configuration to the new model configuration. |
BackboneConfig
¶
Configurations related to model backbone configuration.
Attributes:
Name | Type | Description |
---|---|---|
unet |
Optional[UNetConfig]
|
An instance of |
convnext |
Optional[ConvNextConfig]
|
An instance of |
swint |
Optional[SwinTConfig]
|
An instance of |
Source code in sleap_nn/config/model_config.py
BottomUpConfMapsConfig
¶
Bottomup configuration map.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
Optional[List[str]]
|
(List[str]) None if nodes from sio.Labels file can be used directly. Else provide text name of the body parts (nodes) that the head will be configured to produce. The number of parts determines the number of channels in the output. If not specified, all body parts in the skeleton will be used. This config does not apply for 'PartAffinityFieldsHead'. |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
loss_weight |
Optional[float]
|
(float) Scalar float used to weigh the loss term for this head during training. Increase this to encourage the optimization to focus on improving this specific output in multi-head models. |
Source code in sleap_nn/config/model_config.py
BottomUpConfig
¶
BottomUpMultiClassConfig
¶
CenteredInstanceConfMapsConfig
¶
Centered Instance configuration map.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
Optional[List[str]]
|
(List[str]) None if nodes from sio.Labels file can be used directly. Else provide text name of the body parts (nodes) that the head will be configured to produce. The number of parts determines the number of channels in the output. If not specified, all body parts in the skeleton will be used. This config does not apply for 'PartAffinityFieldsHead'. |
anchor_part |
Optional[str]
|
(str) Node name to use as the anchor point. If None, the midpoint of the bounding box of all visible instance points will be used as the anchor. The bounding box midpoint will also be used if the anchor part is specified but not visible in the instance. Setting a reliable anchor point can significantly improve topdown model accuracy as they benefit from a consistent geometry of the body parts relative to the center of the image. Default is None. |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
loss_weight |
float
|
(float) Scalar float used to weigh the loss term for this head during training. Increase this to encourage the optimization to focus on improving this specific output in multi-head models. |
Source code in sleap_nn/config/model_config.py
CenteredInstanceConfig
¶
CentroidConfMapsConfig
¶
Centroid configuration map.
Attributes:
Name | Type | Description |
---|---|---|
anchor_part |
Optional[str]
|
(str) Node name to use as the anchor point. If None, the midpoint of the bounding box of all visible instance points will be used as the anchor. The bounding box midpoint will also be used if the anchor part is specified but not visible in the instance. Setting a reliable anchor point can significantly improve topdown model accuracy as they benefit from a consistent geometry of the body parts relative to the center of the image. Default is None. |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
Source code in sleap_nn/config/model_config.py
CentroidConfig
¶
ClassMapConfig
¶
Class map head config.
Attributes:
Name | Type | Description |
---|---|---|
classes |
Optional[List[str]]
|
(List[str]) List of class (track) names. Default is |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
loss_weight |
Optional[float]
|
(float) Scalar float used to weigh the loss term for this head during training. Increase this to encourage the optimization to focus on improving this specific output in multi-head models. |
Source code in sleap_nn/config/model_config.py
ClassVectorsConfig
¶
Configurations for class vectors heads.
These heads are used in top-down multi-instance models that classify detected points using a fixed set of learned classes (e.g., animal identities).
Attributes:
Name | Type | Description |
---|---|---|
classes |
Optional[List[str]]
|
List of string names of the classes that this head will predict. |
num_fc_layers |
int
|
Number of fully-connected layers before the classification output layer. These can help in transforming general image features into classification-specific features. |
num_fc_units |
int
|
Number of units (dimensions) in the fully-connected layers before classification. Increasing this can improve the representational capacity in the pre-classification layers. |
output_stride |
int
|
(Ideally this should be same as the backbone's maxstride). The stride of the output class maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in maps that are 0.5x the size of the input. This should be the same size as the confidence maps they are associated with. |
loss_weight |
float
|
Scalar float used to weigh the loss term for this head during training. Increase this to encourage the optimization to focus on improving this specific output in multi-head models. |
Source code in sleap_nn/config/model_config.py
ConvNextBaseConfig
¶
Bases: ConvNextConfig
Convnext configuration for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for ConvNext backbones. For ConvNext, one of ["ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights"]. |
arch |
Optional[dict]
|
(Default is Tiny architecture config. No need to provide if model_type is provided) depths: (List(int)) Number of layers in each block. Default: [3, 3, 9, 3]. channels: (List(int)) Number of channels in each block. Default: [96, 192, 384, 768]. |
model_type |
str
|
(str) One of the ConvNext architecture types: ["tiny", "small", "base", "large"]. Default: "tiny". |
stem_patch_kernel |
int
|
(int) Size of the convolutional kernels in the stem layer. Default is 4. |
stem_patch_stride |
int
|
(int) Convolutional stride in the stem layer. Default is 2. |
in_channels |
int
|
(int) Number of input channels. Default is 1. |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default is 3. |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default is 2. |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default is 2. |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: True. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
max_stride |
int
|
Factor by which input image size is reduced through the layers.
This is always |
Methods:
Name | Description |
---|---|
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
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 |
|
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: convnext_weights are one of ( "ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights", )
Source code in sleap_nn/config/model_config.py
ConvNextConfig
¶
Convnext configuration for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for ConvNext backbones. For ConvNext, one of ["ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights"]. |
arch |
Optional[dict]
|
(Default is Tiny architecture config. No need to provide if model_type is provided)
depths: (List[int]) Number of layers in each block. Default: |
model_type |
str
|
(str) One of the ConvNext architecture types: ["tiny", "small", "base", "large"]. Default: |
stem_patch_kernel |
int
|
(int) Size of the convolutional kernels in the stem layer. Default: |
stem_patch_stride |
int
|
(int) Convolutional stride in the stem layer. Default: |
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
max_stride |
int
|
(int) Factor by which input image size is reduced through the layers. This is always |
Methods:
Name | Description |
---|---|
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: convnext_weights are one of ( "ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights", )
Source code in sleap_nn/config/model_config.py
ConvNextLargeConfig
¶
Bases: ConvNextConfig
Convnext configuration for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for ConvNext backbones. For ConvNext, one of ["ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights"]. |
arch |
Optional[dict]
|
(Default is Tiny architecture config. No need to provide if model_type is provided) depths: (List(int)) Number of layers in each block. Default: [3, 3, 9, 3]. channels: (List(int)) Number of channels in each block. Default: [96, 192, 384, 768]. |
model_type |
str
|
(str) One of the ConvNext architecture types: ["tiny", "small", "base", "large"]. Default: "tiny". |
stem_patch_kernel |
int
|
(int) Size of the convolutional kernels in the stem layer. Default is 4. |
stem_patch_stride |
int
|
(int) Convolutional stride in the stem layer. Default is 2. |
in_channels |
int
|
(int) Number of input channels. Default is 1. |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default is 3. |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default is 2. |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default is 2. |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: True. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
max_stride |
int
|
Factor by which input image size is reduced through the layers.
This is always |
Methods:
Name | Description |
---|---|
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: convnext_weights are one of ( "ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights", )
Source code in sleap_nn/config/model_config.py
ConvNextSmallConfig
¶
Bases: ConvNextConfig
Convnext configuration for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for ConvNext backbones. For ConvNext, one of ["ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights"]. |
arch |
Optional[dict]
|
(Default is Tiny architecture config. No need to provide if model_type is provided) depths: (List(int)) Number of layers in each block. Default: [3, 3, 9, 3]. channels: (List(int)) Number of channels in each block. Default: [96, 192, 384, 768]. |
model_type |
str
|
(str) One of the ConvNext architecture types: ["tiny", "small", "base", "large"]. Default: "tiny". |
stem_patch_kernel |
int
|
(int) Size of the convolutional kernels in the stem layer. Default is 4. |
stem_patch_stride |
int
|
(int) Convolutional stride in the stem layer. Default is 2. |
in_channels |
int
|
(int) Number of input channels. Default is 1. |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default is 3. |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default is 2. |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default is 2. |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: True. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
max_stride |
int
|
Factor by which input image size is reduced through the layers.
This is always |
Methods:
Name | Description |
---|---|
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
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 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 |
|
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: convnext_weights are one of ( "ConvNeXt_Base_Weights", "ConvNeXt_Tiny_Weights", "ConvNeXt_Small_Weights", "ConvNeXt_Large_Weights", )
Source code in sleap_nn/config/model_config.py
HeadConfig
¶
Configurations related to the model output head type.
Only one attribute of this class can be set, which defines the model output type.
Attributes:
Name | Type | Description |
---|---|---|
single_instance |
Optional[SingleInstanceConfig]
|
An instance of |
centroid |
Optional[CentroidConfig]
|
An instance of |
centered_instance |
Optional[CenteredInstanceConfig]
|
An instance of |
bottomup |
Optional[BottomUpConfig]
|
An instance of |
multi_class_bottomup |
Optional[BottomUpMultiClassConfig]
|
An instance of |
multi_class_topdown |
Optional[TopDownCenteredInstanceMultiClassConfig]
|
An instance of |
Source code in sleap_nn/config/model_config.py
ModelConfig
¶
Configurations related to model architecture.
Attributes:
Name | Type | Description |
---|---|---|
init_weights |
str
|
(str) model weights initialization method. "default" uses kaiming uniform initialization and "xavier" uses Xavier initialization method. |
pretrained_backbone_weights |
Optional[str]
|
Path of the |
pretrained_head_weights |
Optional[str]
|
Path of the |
backbone_config |
BackboneConfig
|
initialize either UNetConfig, ConvNextConfig, or SwinTConfig based on input from backbone_type |
head_configs |
HeadConfig
|
(Dict) Dictionary with the following keys having head configs for the model to be trained. Note: Configs should be provided only for the model to train and others should be None |
total_params |
Optional[int]
|
(int) Total number of parameters in the model. This is automatically computed when the training starts. |
Source code in sleap_nn/config/model_config.py
PAFConfig
¶
PAF configuration map.
Attributes:
Name | Type | Description |
---|---|---|
edges |
Optional[List[List[str]]]
|
(List[str]) None if edges from sio.Labels file can be used directly. Note: Only for 'PartAffinityFieldsHead'. List of indices (src, dest) that form an edge. |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
loss_weight |
Optional[float]
|
(float) Scalar float used to weigh the loss term for this head during training. Increase this to encourage the optimization to focus on improving this specific output in multi-head models. |
Source code in sleap_nn/config/model_config.py
SingleInstanceConfMapsConfig
¶
Single Instance configuration map.
Attributes:
Name | Type | Description |
---|---|---|
part_names |
Optional[List[str]]
|
(List[str]) None if nodes from sio.Labels file can be used directly. Else provide text name of the body parts (nodes) that the head will be configured to produce. The number of parts determines the number of channels in the output. If not specified, all body parts in the skeleton will be used. This config does not apply for 'PartAffinityFieldsHead'. |
sigma |
float
|
(float) Spread of the Gaussian distribution of the confidence maps as a scalar float. Smaller values are more precise but may be difficult to learn as they have a lower density within the image space. Larger values are easier to learn but are less precise with respect to the peak coordinate. This spread is in units of pixels of the model input image, i.e., the image resolution after any input scaling is applied. |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. |
Source code in sleap_nn/config/model_config.py
SingleInstanceConfig
¶
SwinTBaseConfig
¶
Bases: SwinTConfig
SwinT configuration for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for SwinT backbones. For SwinT, one of ["Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights"]. |
model_type |
str
|
(str) One of the SwinT architecture types: ["tiny", "small", "base"]. Default: |
arch |
Optional[dict]
|
Dictionary of embed dimension, depths and number of heads in each layer. Default is "Tiny architecture". {'embed': 96, 'depths': [2,2,6,2], 'channels':[3, 6, 12, 24]}. Default: |
max_stride |
int
|
(int) Factor by which input image size is reduced through the layers. This is always |
patch_size |
int
|
(int) Patch size for the stem layer of SwinT. Default: |
stem_patch_stride |
int
|
(int) Stride for the patch. Default: |
window_size |
int
|
(int) Window size. Default: |
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Methods:
Name | Description |
---|---|
validate_model_type |
Validate model_type. |
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
|
validate_model_type(value)
¶
Validate model_type.
Ensure model_type is one of "tiny", "small", or "base".
Source code in sleap_nn/config/model_config.py
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: swint_weights are one of ( "Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights" )
Source code in sleap_nn/config/model_config.py
SwinTConfig
¶
SwinT configuration (tiny) for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for SwinT backbones. For SwinT, one of ["Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights"]. |
model_type |
str
|
(str) One of the SwinT architecture types: ["tiny", "small", "base"]. Default: |
arch |
Optional[dict]
|
Dictionary of embed dimension, depths and number of heads in each layer. Default is "Tiny architecture". {'embed': 96, 'depths': [2,2,6,2], 'channels':[3, 6, 12, 24]}. Default: |
max_stride |
int
|
(int) Factor by which input image size is reduced through the layers. This is always |
patch_size |
int
|
(int) Patch size for the stem layer of SwinT. Default: |
stem_patch_stride |
int
|
(int) Stride for the patch. Default: |
window_size |
int
|
(int) Window size. Default: |
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Methods:
Name | Description |
---|---|
validate_model_type |
Validate model_type. |
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
validate_model_type(value)
¶
Validate model_type.
Ensure model_type is one of "tiny", "small", or "base".
Source code in sleap_nn/config/model_config.py
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: swint_weights are one of ( "Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights" )
Source code in sleap_nn/config/model_config.py
SwinTSmallConfig
¶
Bases: SwinTConfig
SwinT configuration (small) for backbone.
Attributes:
Name | Type | Description |
---|---|---|
pre_trained_weights |
Optional[str]
|
(str) Pretrained weights file name supported only for SwinT backbones. For SwinT, one of ["Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights"]. |
model_type |
str
|
(str) One of the SwinT architecture types: ["tiny", "small", "base"]. Default: |
arch |
Optional[dict]
|
Dictionary of embed dimension, depths and number of heads in each layer. Default is "Tiny architecture". {'embed': 96, 'depths': [2,2,6,2], 'channels':[3, 6, 12, 24]}. Default: |
max_stride |
int
|
(int) Factor by which input image size is reduced through the layers. This is always |
patch_size |
int
|
(int) Patch size for the stem layer of SwinT. Default: |
stem_patch_stride |
int
|
(int) Stride for the patch. Default: |
window_size |
int
|
(int) Window size. Default: |
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Methods:
Name | Description |
---|---|
validate_model_type |
Validate model_type. |
validate_pre_trained_weights |
Validate pre_trained_weights. |
Source code in sleap_nn/config/model_config.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
validate_model_type(value)
¶
Validate model_type.
Ensure model_type is one of "tiny", "small", or "base".
Source code in sleap_nn/config/model_config.py
validate_pre_trained_weights(value)
¶
Validate pre_trained_weights.
Check: swint_weights are one of ( "Swin_T_Weights", "Swin_S_Weights", "Swin_B_Weights" )
Source code in sleap_nn/config/model_config.py
TopDownCenteredInstanceMultiClassConfig
¶
Head config for TopDown centered instance ID models.
Source code in sleap_nn/config/model_config.py
UNetConfig
¶
UNet config for backbone.
Attributes:
Name | Type | Description |
---|---|---|
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters |
int
|
(int) Base number of filters in the network. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
max_stride |
int
|
(int) Scalar integer specifying the maximum stride that the image must be divisible by. Default: |
stem_stride |
Optional[int]
|
(int) If not None, will create additional "down" blocks for initial downsampling based on the stride. These will be configured identically to the down blocks below. Default: |
middle_block |
bool
|
(bool) If True, add an additional block at the end of the encoder. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
stacks |
int
|
(int) Number of upsampling blocks in the decoder. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Source code in sleap_nn/config/model_config.py
UNetLargeRFConfig
¶
Bases: UNetConfig
UNet config for backbone with large receptive field.
Attributes:
Name | Type | Description |
---|---|---|
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters |
int
|
(int) Base number of filters in the network. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
max_stride |
int
|
(int) Scalar integer specifying the maximum stride that the image must be divisible by. Default: |
stem_stride |
Optional[int]
|
(int) If not None, will create additional "down" blocks for initial downsampling based on the stride. These will be configured identically to the down blocks below. Default: |
middle_block |
bool
|
(bool) If True, add an additional block at the end of the encoder. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
stacks |
int
|
(int) Number of upsampling blocks in the decoder. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Source code in sleap_nn/config/model_config.py
UNetMediumRFConfig
¶
Bases: UNetConfig
UNet config for backbone with medium receptive field.
Attributes:
Name | Type | Description |
---|---|---|
in_channels |
int
|
(int) Number of input channels. Default: |
kernel_size |
int
|
(int) Size of the convolutional kernels. Default: |
filters |
int
|
(int) Base number of filters in the network. Default: |
filters_rate |
float
|
(float) Factor to adjust the number of filters per block. Default: |
max_stride |
int
|
(int) Scalar integer specifying the maximum stride that the image must be divisible by. Default: |
stem_stride |
Optional[int]
|
(int) If not None, will create additional "down" blocks for initial downsampling based on the stride. These will be configured identically to the down blocks below. Default: |
middle_block |
bool
|
(bool) If True, add an additional block at the end of the encoder. Default: |
up_interpolate |
bool
|
(bool) If True, use bilinear interpolation instead of transposed convolutions for upsampling. Interpolation is faster but transposed convolutions may be able to learn richer or more complex upsampling to recover details from higher scales. Default: |
stacks |
int
|
(int) Number of upsampling blocks in the decoder. Default: |
convs_per_block |
int
|
(int) Number of convolutional layers per block. Default: |
output_stride |
int
|
(int) The stride of the output confidence maps relative to the input image. This is the reciprocal of the resolution, e.g., an output stride of 2 results in confidence maps that are 0.5x the size of the input. Increasing this value can considerably speed up model performance and decrease memory requirements, at the cost of decreased spatial resolution. Default: |
Source code in sleap_nn/config/model_config.py
model_mapper(legacy_config)
¶
Map the legacy model configuration to the new model configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
legacy_config
|
dict
|
A dictionary containing the legacy model configuration. |
required |
Returns:
Type | Description |
---|---|
ModelConfig
|
An instance of |
Source code in sleap_nn/config/model_config.py
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
|