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. |
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). |
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 |
|---|---|
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 |
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 |
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
|
loss_weight |
float
|
Scalar loss weight. |
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 |
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
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 |
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 |
Optional[List[str]]
|
List of negative sources. |
exclude_same_track |
bool
|
Drop same- |
restrict_same_video |
bool
|
Restrict negatives to same-video pairs. REQUIRED for
|
proximity_filter_px |
Optional[float]
|
Reserved (P2); unused in P1. |
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 (ConvNeXtV2, ResNet, Swinv2,
DINOv2, ...) as the model backbone via transformers AutoBackbone. See
sleap_nn.architectures.pretrained.PretrainedBackbone for the two
integration surfaces (hierarchical decoder vs. encoder-only pooled).
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 ( |
Source code in sleap_nn/config/model_config.py
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 | |
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
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
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 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 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 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | |