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 |
|---|---|
BBoxCenterHeadConfig |
Center-heatmap head of a |
BBoxCenterNetConfig |
Head config for the |
BBoxOffsetHeadConfig |
Sub-cell center offset head of a |
BBoxSSDConfig |
Head config for the |
BBoxSizeHeadConfig |
Box-size regression head of a |
BackboneConfig |
Configurations related to model backbone configuration. |
BottomUpConfMapsConfig |
Bottomup configuration map. |
BottomUpConfig |
bottomup head_config. |
BottomUpMultiClassConfig |
Head config for BottomUp Id models. |
BottomUpSegmentationConfig |
Head config for bottom-up instance segmentation models. |
CenterOffsetConfig |
Configuration for the center offset head. |
CenteredInstanceConfMapsConfig |
Centered Instance configuration map. |
CenteredInstanceConfig |
centered_instance head_config. |
CenteredInstanceSegmentationConfig |
Head config for top-down crop-centered instance segmentation models. |
CenteredInstanceSegmentationHeadConfig |
Foreground-mask head config for top-down crop-centered segmentation. |
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. |
EmbeddingConfig |
Head config for the |
EmbeddingHeadConfig |
Configuration for the embedding head (the adapter on a pooled encoder feature). |
HeadConfig |
Configurations related to the model output head type. |
InstanceCenterConfig |
Configuration for the instance center heatmap head. |
LossConfig |
Contrastive loss for the embedding objective (the loss axis). |
ModelConfig |
Configurations related to model architecture. |
NegativesConfig |
Negative-pair eligibility for the embedding objective. |
ObjectiveConfig |
Pluggable training objective = positives x negatives x loss. |
PAFConfig |
PAF configuration map. |
PositivesConfig |
Positive-pair sampling for the embedding objective. |
PretrainedConfig |
Configuration for an external pretrained backbone (HuggingFace). |
SSDHeadConfig |
Multi-scale anchor head of a |
SamplerConfig |
Group-aware batch sampler that realizes the objective. |
SegmentationHeadConfig |
Configuration for the foreground segmentation head. |
SemanticSegmentationConfig |
Head config for whole-frame semantic (foreground) segmentation models. |
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 |
|---|---|
drop_removed_embedding_keys |
Remove the removed embedding keys from an embedding head leaf, in place. |
model_mapper |
Map the legacy model configuration to the new model configuration. |
resolve_embedding_objective |
Return the embedding objective with every sub-config filled in and validated. |
ssd_level_strides |
Pyramid level strides of an |
BBoxCenterHeadConfig
¶
Center-heatmap head of a bbox_centernet model.
One sigmoid heatmap channel per category with a Gaussian peak at each box center (CenterNet, Zhou et al. 2019), trained with the penalty-reduced pixelwise focal loss of CornerNet/CenterNet.
Attributes:
| Name | Type | Description |
|---|---|---|
categories |
Optional[List[str]]
|
(List[str]) Ordered class names; one heatmap channel per entry.
|
sigma |
Optional[float]
|
(float) Fixed Gaussian sigma in input pixels. |
min_overlap |
float
|
(float) IoU used by the size-adaptive radius. Default: |
output_stride |
int
|
(int) Stride of the heatmap relative to the input image.
Must equal the |
loss_weight |
float
|
(float) Weight of the heatmap focal loss. Default: |
focal_alpha |
float
|
(float) Focal exponent on the prediction error. Default:
|
focal_beta |
float
|
(float) Exponent of the penalty reduction around GT peaks.
Default: |
Source code in sleap_nn/config/model_config.py
BBoxCenterNetConfig
¶
Head config for the bbox_centernet (CenterNet-style) model type.
A whole-frame, anchor-free detector: a center heatmap plus per-center size and offset regression. Decoding takes the heatmap's local maxima as detections and reads each one's box from the size/offset maps (no anchors, no grouping).
Source code in sleap_nn/config/model_config.py
BBoxOffsetHeadConfig
¶
Sub-cell center offset head of a bbox_centernet model.
Two channels recovering the center's position inside its output-grid cell, i.e. the quantization error of the stride, with an L1 loss masked to center cells.
Attributes:
| Name | Type | Description |
|---|---|---|
output_stride |
int
|
(int) Must equal the center head's stride. Default: |
loss_weight |
float
|
(float) Weight of the offset L1 loss. Default: |
Source code in sleap_nn/config/model_config.py
BBoxSSDConfig
¶
Head config for the bbox_ssd (SSD-style, anchor-based) model type.
Wraps the single multi-scale ssd leaf (mirrors SemanticSegmentationConfig).
Source code in sleap_nn/config/model_config.py
BBoxSizeHeadConfig
¶
Box-size regression head of a bbox_centernet model.
Two channels (width, height) regressed at each box's center cell, in units of output-grid cells, with an L1 loss masked to center cells.
Attributes:
| Name | Type | Description |
|---|---|---|
output_stride |
int
|
(int) Must equal the center head's stride. Default: |
loss_weight |
float
|
(float) Weight of the size L1 loss. Default: |
Source code in sleap_nn/config/model_config.py
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 |
pretrained |
Optional[PretrainedConfig]
|
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
¶
BottomUpSegmentationConfig
¶
Head config for bottom-up instance segmentation models.
Source code in sleap_nn/config/model_config.py
CenterOffsetConfig
¶
Configuration for the center offset head.
Attributes:
| Name | Type | Description |
|---|---|---|
output_stride |
int
|
(int) The stride of the output offset maps relative to the input image. Default: 2. |
loss_weight |
float
|
(float) Scalar float used to weigh the loss term for this head during training. Default: 0.1. |
Source code in sleap_nn/config/model_config.py
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 NaN-ignoring mean of all visible instance nodes will be used as the anchor. The same mean-of-visible-nodes fallback is used when 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. |
centroid_method |
Optional[str]
|
(str) How the crop center is derived from the instance's
points, spelled as in |
centroid_fallback |
Optional[str]
|
(str) The reduce method used when |
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
¶
CenteredInstanceSegmentationConfig
¶
Head config for top-down crop-centered instance segmentation models.
A single foreground-mask head predicting the centered instance's mask on a
centroid crop (the segmentation analog of centered_instance; composed
with a centroid model for full top-down inference).
Source code in sleap_nn/config/model_config.py
CenteredInstanceSegmentationHeadConfig
¶
Foreground-mask head config for top-down crop-centered segmentation.
The bottom-up SegmentationHeadConfig fields plus anchor_part. Keeping
anchor_part INSIDE the head leaf (rather than as a sibling of
segmentation) matches centered_instance's confmaps.anchor_part and
the codebase invariant that every per-type head config is a dict of head-leaf
configs each carrying output_stride — so model/config code that iterates
head leaves (loss weights, output strides, etc.) never trips over it.
Attributes:
| Name | Type | Description |
|---|---|---|
output_stride |
int
|
(int) Stride of the output mask relative to the input crop. Default: 2. |
loss_weight |
float
|
(float) Scalar weight for the bce-dice loss term. Default: 1.0. |
anchor_part |
Optional[str]
|
(str) Optional node name used to center crops during
training. |
centroid_method |
Optional[str]
|
(str) How the centroid is derived from the instance's
points, spelled as in |
centroid_fallback |
Optional[str]
|
(str) The reduce method used when |
Source code in sleap_nn/config/model_config.py
CentroidConfMapsConfig
¶
Centroid configuration map.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_part |
Optional[str]
|
(str) Node name to use as the anchor point. If None, the NaN-ignoring mean of all visible instance nodes will be used as the anchor. The same mean-of-visible-nodes fallback is used when 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. |
centroid_method |
Optional[str]
|
(str) How the centroid is derived from the instance's
points, spelled as in |
centroid_fallback |
Optional[str]
|
(str) The reduce method used when |
centroid_source |
Optional[str]
|
(str) Which centroid the model is trained to predict.
The centroid head must use ONE source for the whole dataset —
mixing user-annotated and computed centroids trains the head against
two conflicting definitions of "centroid". Options:
- |
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. |
use_sigmoid_activation |
bool
|
(bool) If |
focal_loss_alpha |
float
|
(float) If nonzero, replaces the plain MSE train loss with a
CenterNet/CornerNet-style penalty-reduced pixelwise focal loss (see
|
focal_loss_beta |
float
|
(float) Penalty-reduction exponent for negative pixels near a
true peak. Only has an effect when |
focal_loss_pos_threshold |
float
|
(float) Minimum target confmap value for a pixel to
count as "positive" (near a true peak) in the focal loss. sleap-nn's
Gaussian confmap targets are continuous (sub-pixel), so the peak pixel's
value is rarely exactly |
Source code in sleap_nn/config/model_config.py
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
CentroidConfig
¶
ClassMapConfig
¶
Class map head config.
Attributes:
| Name | Type | Description |
|---|---|---|
classes |
Optional[List[str]]
|
(List[str]) List of class (track) names. Default is |
class_output |
str
|
(str) How a predicted class is interpreted as an |
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. |
class_output |
str
|
How a predicted class is interpreted as an |
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
EmbeddingConfig
¶
Head config for the embedding (crop -> vector, re-ID) model type.
A single pooled-encoder head producing a per-instance embedding vector. Wraps
one leaf head config (mirrors CenteredInstanceSegmentationConfig).
Source code in sleap_nn/config/model_config.py
EmbeddingHeadConfig
¶
Configuration for the embedding head (the adapter on a pooled encoder feature).
Shape mirrors ClassVectorsConfig: [pool] -> Flatten -> N x (Linear+ReLU) ->
Linear(embedding_dim) -> [L2Norm]. The training objective is nested here.
Attributes:
| Name | Type | Description |
|---|---|---|
embedding_dim |
int
|
Output embedding dimensionality. |
num_fc_layers |
int
|
Number of FC layers before the embedding output. |
num_fc_units |
int
|
Units in the pre-embedding FC layers. |
pool |
Optional[str]
|
Pooling over the encoder feature map. One of |
normalize |
bool
|
L2-normalize the embedding (applied identically train + inference). |
output_stride |
int
|
Stride of the pooled feature. Should equal the backbone
|
freeze_backbone |
bool
|
(bool) Freeze the backbone's PRETRAINED ENCODER and train
only what sits on top of it. The encoder is the part pretrained weights
load into: the HuggingFace model of a |
anchor_part |
Optional[str]
|
(str) Node name used to center the re-ID crop. |
centroid_method |
Optional[str]
|
(str) How the crop center is derived from the instance's
points, spelled as in |
detection_mode |
Optional[str]
|
(str) The detection carrier the model crops: |
centroid_fallback |
Optional[str]
|
(str) The reduce method used when |
objective |
Optional[ObjectiveConfig]
|
The pluggable training objective (positives x negatives x loss). |
Source code in sleap_nn/config/model_config.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | |
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 |
bottomup_segmentation |
Optional[BottomUpSegmentationConfig]
|
An instance of |
centered_instance_segmentation |
Optional[CenteredInstanceSegmentationConfig]
|
An instance of
|
semantic_segmentation |
Optional[SemanticSegmentationConfig]
|
An instance of |
embedding |
Optional[EmbeddingConfig]
|
An instance of |
bbox_centernet |
Optional[BBoxCenterNetConfig]
|
An instance of |
bbox_ssd |
Optional[BBoxSSDConfig]
|
An instance of |
Source code in sleap_nn/config/model_config.py
InstanceCenterConfig
¶
Configuration for the instance center heatmap head.
This config is used exclusively by the bottomup_segmentation head; it does
not affect centroid (CentroidConfMapsConfig.sigma) or bottom-up pose
(BottomUpConfMapsConfig) models.
Attributes:
| Name | Type | Description |
|---|---|---|
sigma |
float
|
(float) Standard deviation of the Gaussian distribution used to generate center heatmaps, in pixels at original image resolution. Default: 4.0. Caveat: 4.0 was validated empirically on mice only (compact bodies; it cut learned center over-detection from 60.75 to 14.2 peaks/frame relative to the old default of 10.0, which over-fires badly on elongated bodies). It is the better general default than 10.0, but the optimal value is dataset-dependent: elongated/large animals may want a larger sigma, tiny animals smaller. The target Gaussian is always isotropic (anisotropic targets were tested and performed worse). Because this is a per-head config field, users can tune it per dataset without affecting any other model type. |
output_stride |
int
|
(int) The stride of the output center heatmaps relative to the input image. Default: 2. |
loss_weight |
float
|
(float) Scalar float used to weigh the loss term for this head during training. Default: 1.0. |
Source code in sleap_nn/config/model_config.py
LossConfig
¶
Contrastive loss for the embedding objective (the loss axis).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
One of |
temperature |
float
|
Softmax temperature for |
margin |
float
|
Margin for |
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
NegativesConfig
¶
Negative-pair eligibility for the embedding objective.
A negative must be a KNOWN-different pair, never merely "not known-positive".
Attributes:
| Name | Type | Description |
|---|---|---|
sources |
List[str]
|
List of negative sources. |
exclude_same_track |
bool
|
Drop same- |
restrict_same_video |
bool
|
Restrict negatives to same-video pairs. REQUIRED for
|
Source code in sleap_nn/config/model_config.py
ObjectiveConfig
¶
Pluggable training objective = positives x negatives x loss.
The sampler composes the batch, a mask-builder turns each item's
(video, frame, group, item_id) into (pos_mask, neg_mask), and the loss
consumes (embeddings, pos_mask, neg_mask).
Attributes:
| Name | Type | Description |
|---|---|---|
positives |
Optional[PositivesConfig]
|
Positive-pair sampling config. |
negatives |
Optional[NegativesConfig]
|
Negative-pair eligibility config. |
loss |
Optional[LossConfig]
|
Contrastive loss config. |
sampler |
Optional[SamplerConfig]
|
Group-aware batch sampler config. |
use_projection |
bool
|
Add a train-only projection head (discarded at inference)
for |
projection_dim |
int
|
Width of the projection head. |
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
PositivesConfig
¶
Positive-pair sampling for the embedding objective.
Attributes:
| Name | Type | Description |
|---|---|---|
scope |
str
|
Which crops are positives of an anchor. One of
|
aug_views |
int
|
Number of augmented views of each anchor (always positives).
Fixed at 2 (the standard two-view contrastive setup the |
Source code in sleap_nn/config/model_config.py
PretrainedConfig
¶
Configuration for an external pretrained backbone (HuggingFace).
Reuses an external pretrained image encoder from the HuggingFace Hub as the
model backbone: hierarchical encoders (ConvNeXtV2, ResNet, Swinv2, DINOv3
ConvNeXt, ...) via transformers AutoBackbone, and plain ViTs (DINOv2/v3,
CLIP, SigLIP, MAE, ...) via AutoModel hidden states; timm/... ids load
through transformers' TimmWrapperModel. See
sleap_nn.architectures.pretrained.PretrainedBackbone for the three
integration surfaces (hierarchical decoder, encoder-only pooled, plain ViT +
pyramid neck + decoder).
Attributes:
| Name | Type | Description |
|---|---|---|
source |
str
|
(str) Backbone source. Only |
model_name |
str
|
(str) HuggingFace model id, e.g.
|
weights |
bool
|
(bool) If |
mode |
str
|
(str) One of |
freeze |
bool
|
(bool) If |
revision |
Optional[str]
|
(str) Optional HuggingFace revision (commit sha / tag) to pin for
reproducibility. Default: |
normalize |
bool
|
(bool) If |
image_mean |
Optional[List[float]]
|
(List[float]) Optional explicit per-channel mean (length 3). If
|
image_std |
Optional[List[float]]
|
(List[float]) Optional explicit per-channel std (length 3).
Default: |
out_indices |
Optional[List[int]]
|
(List[int]) Optional explicit stage indices to tap (Case A).
If |
in_channels |
int
|
(int) Number of input channels the stem expects. Pretrained
stems are 3-channel; grayscale is replicated upstream. Default: |
filters_rate |
float
|
(float) Decoder filter growth factor (Case A). Default: |
convs_per_block |
int
|
(int) Refinement convs per decoder block (Case A).
Default: |
kernel_size |
int
|
(int) Decoder conv kernel size (Case A). Default: |
up_interpolate |
bool
|
(bool) Bilinear upsampling (vs. transposed conv) in the
decoder (Case A). Default: |
output_stride |
int
|
(int) Stride of the finest decoder output (Case A).
Default: |
max_stride |
int
|
(int) Deepest stride the encoder reaches ( |
layers |
Optional[List[int]]
|
(List[int]) Plain-ViT layers to tap for the feature-pyramid neck,
1-indexed (negative counts from the last). |
vit_neck |
str
|
(str) How a plain ViT's single-stride token maps become the
stride |
neck_channels |
Optional[List[int]]
|
(List[int]) Channels of the 4 neck levels, finest first.
|
token_stride |
Optional[int]
|
(int) Effective stride of a plain ViT's token grid; the
input is resampled so the grid is |
gradient_checkpointing |
bool
|
(bool) Enable gradient checkpointing in the
encoder while training (less memory, slower). Default: |
encoder_lr_scale |
float
|
(float) Learning-rate multiplier for the pretrained
encoder relative to the neck/decoder/heads. Default: |
layer_decay |
Optional[float]
|
(float) Optional layer-wise LR decay for a plain ViT
encoder: block |
detail_stem |
bool
|
(bool) Add a light conv stream on the image whose stride
2/4/8 features join a plain ViT's pyramid as decoder skips (real
high-resolution detail below the token stride). Default: |
detail_channels |
Optional[List[int]]
|
(List[int]) Detail-stem channels at strides 2, 4, 8
(exactly three). |
Source code in sleap_nn/config/model_config.py
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 | |
SSDHeadConfig
¶
Multi-scale anchor head of a bbox_ssd (SSD-style) model.
Binds to num_levels feature maps of the backbone at strides
output_stride * 2**i (the decoder's top-down path is the feature pyramid;
the bottleneck supplies the deepest level). Each level runs a small conv tower
and predicts, for each of its anchors, len(categories) + 1 class logits
(index 0 is background) and 4 box deltas in SSD's (cx, cy, w, h) encoding.
Training matches anchors to boxes by IoU and uses softmax cross-entropy with
hard negative mining plus smooth-L1 on the positives (Liu et al. 2016).
Attributes:
| Name | Type | Description |
|---|---|---|
categories |
Optional[List[str]]
|
(List[str]) Ordered class names (background excluded). |
output_stride |
int
|
(int) Stride of the finest pyramid level. Default: |
num_levels |
int
|
(int) Number of pyramid levels. The deepest one,
|
anchor_sizes |
Optional[List[float]]
|
(List[float]) Base anchor size (sqrt of the area, in input
pixels) per level, finest first. |
anchor_scales |
List[float]
|
(List[float]) Multipliers on each level's base size.
Default: |
aspect_ratios |
List[float]
|
(List[float]) Anchor |
pos_iou_threshold |
float
|
(float) An anchor with IoU >= this with some box is a
positive for it. Each box's best anchor is always a positive too.
Default: |
neg_iou_threshold |
float
|
(float) Anchors whose best IoU is below this are
background; those in between are ignored. Default: |
neg_pos_ratio |
float
|
(float) Hard negative mining keeps this many of the
highest-loss background anchors per positive. Default: |
box_variances |
List[float]
|
(List[float]) SSD's |
head_channels |
int
|
(int) Channels of each level's conv tower. Default:
|
head_convs |
int
|
(int) 3x3 conv + ReLU layers in each level's tower before the
predictors. Default: |
loss_weight |
float
|
(float) Weight of the box regression loss relative to the
classification loss. Default: |
Source code in sleap_nn/config/model_config.py
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 | |
SamplerConfig
¶
Group-aware batch sampler that realizes the objective.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
|
groups_per_batch |
int
|
P — number of groups (identities/tracklets) per batch. |
samples_per_group |
int
|
K — crops per group per batch. The effective batch size is
|
Source code in sleap_nn/config/model_config.py
SegmentationHeadConfig
¶
Configuration for the foreground segmentation head.
Shared by bottomup_segmentation and semantic_segmentation (both a
plain foreground head). The loss / target knobs default to the historical
behavior, so an unset config trains exactly as before.
Attributes:
| Name | Type | Description |
|---|---|---|
output_stride |
int
|
(int) The stride of the output segmentation maps relative to the
input image. Default: 2. Setting |
loss_weight |
float
|
(float) Scalar float used to weigh the loss term for this head during training. Default: 1.0. |
bce_weight |
float
|
(float) Weight of the BCE term in the bce-dice foreground loss. Default: 0.5. Tilt toward Dice (e.g. 0.3 BCE / 0.7 Dice) to reduce the easy-background/thick-object dominance for thin foreground. |
dice_weight |
float
|
(float) Weight of the Dice term in the bce-dice loss. Default: 0.5. |
bce_pos_weight |
Optional[float]
|
(Optional[float]) Positive-class weight for the BCE term. For
thin/rare foreground (<1% of pixels), a value >1 (e.g. ~5-20) up-weights
the foreground so the head stays confident on faint thin structures.
|
target_maxpool |
bool
|
(bool) Downsample the foreground target with max-pool
semantics (any foreground pixel in a stride cell -> foreground) instead of
area-average + 0.5 threshold. Default: |
Source code in sleap_nn/config/model_config.py
SemanticSegmentationConfig
¶
Head config for whole-frame semantic (foreground) segmentation models.
A single foreground-mask head predicting one binary foreground/background mask
over the whole frame — no instance grouping, no center/offset heads. It is
the whole-frame analog of centered_instance_segmentation (which runs the
same fg-only SegmentationHead on a centroid crop) and the group-free
sibling of bottomup_segmentation (which adds center + offset heads to group
the foreground into instances). Tiling-compatible.
Reuses the bottom-up SegmentationHeadConfig leaf (output_stride +
loss_weight); it carries no anchor_part because there is no crop.
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
drop_removed_embedding_keys(leaf, where=_EMBEDDING_LEAF)
¶
Remove the removed embedding keys from an embedding head leaf, in place.
Logs a warning per key removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
leaf
|
The |
required | |
where
|
str
|
The leaf's config path, for the warning. |
_EMBEDDING_LEAF
|
Returns:
| Type | Description |
|---|---|
|
The names of the keys removed (full config paths). |
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
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 | |
resolve_embedding_objective(objective)
¶
Return the embedding objective with every sub-config filled in and validated.
The single reading of head_configs.embedding.embedding.objective shared by
the EmbeddingLightningModule, the identity validator and the batch sampler, so
they cannot disagree about a default (negatives.sources defaulting to None
once meant "both sources" to one reader and "no negatives" to another). The
defaults are the attrs defaults above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objective
|
The |
required |
Returns:
| Type | Description |
|---|---|
ObjectiveConfig
|
A fully-populated |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a field has an unknown value (e.g. a misspelled
|
Source code in sleap_nn/config/model_config.py
ssd_level_strides(ssd_config)
¶
Pyramid level strides of an SSDHeadConfig (or its DictConfig), finest first.