topdown_multiclass
sleap_nn.inference.layers.topdown_multiclass
¶
TopDownMultiClassLayer — multi-class variant of top-down inference.
Composes :class:CentroidLayer with a multi-class centered-instance
CenteredInstanceMultiClassLayer (defined in this module). The
multi-class centered-instance model emits keypoint confmaps plus a
ClassVectorsHead per crop; the layer adds a class-prob output to
Outputs.instance_scores and a per-node class-index field.
Classes:
| Name | Description |
|---|---|
CenteredInstanceMultiClassLayer |
Centered-instance + per-instance class vector head. |
TopDownMultiClassLayer |
Top-down with per-instance class identity. |
CenteredInstanceMultiClassLayer
¶
Bases: InferenceLayer
Centered-instance + per-instance class vector head.
Per-crop, returns keypoints (like CenteredInstanceLayer) plus a
class index and class probability from a softmax-classified
ClassVectorsHead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ModelBackend
|
Runtime backend wrapping the multi-class centered- instance Lightning module. |
required |
output_stride
|
int
|
Confmap output stride. |
required |
max_stride
|
int
|
Max stride for input divisibility (preprocess pads bottom-right). |
1
|
preprocess_config / postprocess_config
|
Standard knobs. |
required | |
class_names
|
Optional[list[str]]
|
Ordered class names from
|
None
|
Notes
Class-level use_gt_peaks = False: the multi-class variant does
not support the GT-keypoints fallback path (you can't match GT
classes to GT keypoints the way the plain centered-instance layer
matches centroids → keypoints). The attribute is exposed so
:class:TopDownLayer-derived composers can branch on it
uniformly without isinstance checks.
Methods:
| Name | Description |
|---|---|
__init__ |
Compose the layer with the standard centered-instance config. |
postprocess |
Decode confmaps to keypoints; classify via |
Source code in sleap_nn/inference/layers/topdown_multiclass.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
__init__(backend, output_stride, max_stride=1, preprocess_config=None, postprocess_config=None, class_names=None, class_output='track')
¶
Compose the layer with the standard centered-instance config.
Source code in sleap_nn/inference/layers/topdown_multiclass.py
postprocess(raw_out, info)
¶
Decode confmaps to keypoints; classify via ClassVectorsHead.
Source code in sleap_nn/inference/layers/topdown_multiclass.py
TopDownMultiClassLayer
¶
Bases: TopDownLayer
Top-down with per-instance class identity.
Same composition as :class:TopDownLayer (stage 1 = centroid, stage
2 = centered-instance) but the centered-instance layer is a
:class:CenteredInstanceMultiClassLayer whose output carries class
indices + probabilities. The composition logic is unchanged — class
fields propagate through stage 2 unchanged.
Methods:
| Name | Description |
|---|---|
__init__ |
Forward to |
Attributes:
| Name | Type | Description |
|---|---|---|
class_names |
Optional[list[str]]
|
Class names from the inner multi-class centered-instance layer. |
class_output |
str
|
Class-output mode from the inner multi-class centered-instance layer. |
Source code in sleap_nn/inference/layers/topdown_multiclass.py
class_names
property
¶
Class names from the inner multi-class centered-instance layer.
class_output
property
¶
Class-output mode from the inner multi-class centered-instance layer.
__init__(centroid_layer, centered_instance_layer, crop_size, centroid_nms=False, centroid_nms_threshold=0.5, return_crops=False)
¶
Forward to TopDownLayer after type-checking the inner layer.