configs
sleap_nn.inference.layers.configs
¶
PreprocessConfig / PostprocessConfig — value types parameterizing layers.
Both are attrs.frozen so they hash, serialize, and never silently mutate
after a layer has been constructed. PostprocessConfig is shared by every
layer subclass; PreprocessConfig mirrors the data_config.preprocessing
section of the training config so layer factories can populate it directly.
Classes:
| Name | Description |
|---|---|
PostprocessConfig |
Knobs that govern how raw model outputs become keypoints. |
PreprocessConfig |
Preprocessing knobs applied before the model forward pass. |
PostprocessConfig
¶
Knobs that govern how raw model outputs become keypoints.
Distinct from the post-inference FilterConfig: this struct governs
the decoding step (peak finding, integral refinement, NMS), while
FilterConfig filters the keypoints that come out the other side.
peak_threshold here decides which confmap pixels become peaks;
min_peak_value in FilterConfig filters peaks the decoder
already returned.
Attributes:
| Name | Type | Description |
|---|---|---|
peak_threshold |
float
|
Minimum confmap activation to consider a peak. |
refinement |
Literal['integral', 'none']
|
|
integral_patch_size |
int
|
Side length of the refinement patch. |
max_instances |
Optional[int]
|
Cap on instances per frame (centroid layer only). |
return_confmaps |
bool
|
Keep |
return_pafs |
bool
|
Keep |
return_paf_graph |
bool
|
Keep the bottom-up PAF graph tuple (opt-in). |
return_class_maps |
bool
|
Keep |
return_class_vectors |
bool
|
Keep |
Source code in sleap_nn/inference/layers/configs.py
effective_refinement
property
¶
Return the refinement string or None when "none".
Every postprocess site needs refinement=None (not the string
"none") to disable refinement. This property centralises that
coercion.
PreprocessConfig
¶
Preprocessing knobs applied before the model forward pass.
Defaults are the no-op identity for every field — calling the layer on an already-correctly-shaped batch produces zero extra work.
Attributes:
| Name | Type | Description |
|---|---|---|
ensure_rgb |
Optional[bool]
|
|
ensure_grayscale |
Optional[bool]
|
Inverse of |
max_height |
Optional[int]
|
Resize so height ≤ this (preserves aspect ratio). |
max_width |
Optional[int]
|
Same for width. |
scale |
float
|
Multiplicative input-scale factor applied (after size matching)
via :func: |
crop_size |
Optional[Tuple[int, int]]
|
Top-down stage 2 only — square crop side length. |
Methods:
| Name | Description |
|---|---|
__attrs_post_init__ |
Reject the contradictory |
Source code in sleap_nn/inference/layers/configs.py
__attrs_post_init__()
¶
Reject the contradictory ensure_rgb=True + ensure_grayscale=True.