recommender
sleap_nn.config_generator.recommender
¶
Pipeline and parameter recommendation logic.
This module provides intelligent recommendations for training configuration based on dataset statistics extracted from SLP files.
Classes:
| Name | Description |
|---|---|
ConfigRecommendation |
Complete configuration recommendation. |
PipelineRecommendation |
Recommendation for which pipeline to use. |
Functions:
| Name | Description |
|---|---|
recommend_config |
Generate complete configuration recommendation. |
recommend_pipeline |
Recommend the best pipeline based on dataset statistics. |
ConfigRecommendation
dataclass
¶
Complete configuration recommendation.
Attributes:
| Name | Type | Description |
|---|---|---|
pipeline |
PipelineRecommendation
|
Pipeline recommendation. |
backbone |
BackboneType
|
Recommended backbone architecture. |
backbone_reason |
str
|
Explanation for backbone choice. |
sigma |
float
|
Recommended sigma value for confidence maps. |
sigma_reason |
str
|
Explanation for sigma choice. |
input_scale |
float
|
Recommended input scaling factor. |
scale_reason |
str
|
Explanation for scale choice. |
batch_size |
int
|
Recommended batch size. |
batch_reason |
str
|
Explanation for batch size choice. |
rotation_range |
Tuple[float, float]
|
Recommended rotation augmentation range (min, max). |
rotation_reason |
str
|
Explanation for rotation choice. |
crop_size |
Optional[int]
|
Recommended crop size for centered_instance models. |
anchor_part |
Optional[str]
|
Recommended anchor part for top-down models. |
Source code in sleap_nn/config_generator/recommender.py
PipelineRecommendation
dataclass
¶
Recommendation for which pipeline to use.
Attributes:
| Name | Type | Description |
|---|---|---|
recommended |
PipelineType
|
The recommended pipeline type. |
reason |
str
|
Human-readable explanation for the recommendation. |
alternatives |
List[PipelineType]
|
List of alternative pipeline types. |
warnings |
List[str]
|
List of warning messages. |
requires_second_model |
bool
|
Whether top-down requires a second model. |
second_model_type |
Optional[PipelineType]
|
The type of the second model (if required). |
Source code in sleap_nn/config_generator/recommender.py
recommend_config(stats, view_type=ViewType.UNKNOWN)
¶
Generate complete configuration recommendation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stats
|
DatasetStats
|
DatasetStats from analyze_slp(). |
required |
view_type
|
ViewType
|
Camera view (side, top, or unknown). |
UNKNOWN
|
Returns:
| Type | Description |
|---|---|
ConfigRecommendation
|
ConfigRecommendation with all parameter suggestions. |
Example
stats = analyze_slp("labels.slp") rec = recommend_config(stats, ViewType.TOP) print(f"Pipeline: {rec.pipeline.recommended}") print(f"Backbone: {rec.backbone}")
Source code in sleap_nn/config_generator/recommender.py
recommend_pipeline(stats)
¶
Recommend the best pipeline based on dataset statistics.
Decision tree: 1. Single animal per frame -> single_instance 2. Multiple small animals (<20% frame area) -> top-down (centroid) 3. Multiple large animals with edges -> bottomup 4. Multiple large animals without edges -> top-down (centroid)
Note: Multi-class models are available as alternatives when tracks exist, but are not recommended by default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stats
|
DatasetStats
|
DatasetStats from analyze_slp(). |
required |
Returns:
| Type | Description |
|---|---|
PipelineRecommendation
|
PipelineRecommendation with suggested pipeline and reasoning. |
Example
stats = analyze_slp("labels.slp") rec = recommend_pipeline(stats) print(f"Use {rec.recommended}: {rec.reason}")
Source code in sleap_nn/config_generator/recommender.py
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |