|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from dataclasses import dataclass, field |
4 | | -from typing import Any, Dict, List, Optional, Tuple |
| 4 | +from typing import Any, Dict, List, Optional |
5 | 5 |
|
6 | 6 | from .system import SystemConfig |
7 | 7 |
|
@@ -157,102 +157,6 @@ class InferenceMemoryCleanupConfig: |
157 | 157 | release_model_after_inference: bool = False |
158 | 158 |
|
159 | 159 |
|
160 | | -@dataclass |
161 | | -class DecodeBinaryContourDistanceWatershedConfig: |
162 | | - """Parameters for binary+contour+distance watershed decoding.""" |
163 | | - |
164 | | - binary_threshold: Tuple[float, float] = (0.9, 0.8) |
165 | | - contour_threshold: Tuple[float, float] = (0.5, 0.5) |
166 | | - distance_threshold: Tuple[float, float] = (0.5, -0.5) |
167 | | - min_instance_size: int = 10 |
168 | | - min_seed_size: int = 10 |
169 | | - seed_distance_scale: float = 1.0 |
170 | | - |
171 | | - |
172 | | -@dataclass |
173 | | -class DecodeModeConfig: |
174 | | - """Single decode mode configuration.""" |
175 | | - |
176 | | - enabled: bool = True |
177 | | - name: str = "decode_semantic" |
178 | | - kwargs: Dict[str, Any] = field(default_factory=dict) |
179 | | - |
180 | | - |
181 | | -@dataclass |
182 | | -class BinaryPostprocessingConfig: |
183 | | - """Binary postprocessing pipeline configuration.""" |
184 | | - |
185 | | - enabled: bool = False # Enable binary postprocessing pipeline |
186 | | - median_filter_size: Optional[Tuple[int, ...]] = ( |
187 | | - None # Median filter kernel size (e.g., (3, 3) for 2D) |
188 | | - ) |
189 | | - opening_iterations: int = 0 # Number of morphological opening iterations |
190 | | - closing_iterations: int = 0 # Number of morphological closing iterations |
191 | | - connected_components: Optional[ConnectedComponentsConfig] = None # CC filtering config |
192 | | - |
193 | | - |
194 | | -@dataclass |
195 | | -class ConnectedComponentsConfig: |
196 | | - """Connected components filtering configuration.""" |
197 | | - |
198 | | - enabled: bool = False # Enable connected components filtering |
199 | | - top_k: Optional[int] = None # Keep only top-k largest components (None = keep all) |
200 | | - min_size: int = 0 # Minimum component size in voxels |
201 | | - connectivity: int = 1 # Connectivity for CC (1=face, 2=face+edge, 3=face+edge+corner) |
202 | | - |
203 | | - |
204 | | -@dataclass |
205 | | -class PostprocessingConfig: |
206 | | - """Postprocessing configuration for inference output. |
207 | | -
|
208 | | - Controls how decoded outputs are transformed after decoding: |
209 | | - - Binary refinement: Morphological operations and connected components filtering |
210 | | - - Transpose: Reorder axes (e.g., [2,1,0] for zyx->xyz) |
211 | | -
|
212 | | - Note: raw prediction scaling/dtype changes that should affect decoding are |
213 | | - handled by PredictionTransformConfig. Save-only encoding is handled by |
214 | | - SavePredictionConfig. |
215 | | - """ |
216 | | - |
217 | | - enabled: bool = False # Enable postprocessing pipeline |
218 | | - |
219 | | - # Binary segmentation refinement (morphological ops, connected components) |
220 | | - binary: Optional[Dict[str, Any]] = field( |
221 | | - default_factory=dict |
222 | | - ) # Binary postprocessing config (e.g., {'opening_iterations': 2}) |
223 | | - |
224 | | - # Instance cc3d relabeling: split disconnected components and remove small ones |
225 | | - instance_cc3d: Optional[Dict[str, Any]] = None |
226 | | - # Example: {connectivity: 6, min_size: 100, remove_boundary: false} |
227 | | - |
228 | | - # Axis permutation |
229 | | - output_transpose: List[int] = field( |
230 | | - default_factory=list |
231 | | - ) # Axis permutation for output (e.g., [2,1,0] for zyx->xyz) |
232 | | - |
233 | | - |
234 | | -@dataclass |
235 | | -class EvaluationConfig: |
236 | | - """Evaluation configuration.""" |
237 | | - |
238 | | - enabled: bool = False # Auto-enabled when evaluation keys are provided in YAML |
239 | | - metrics: Optional[List[str]] = None # e.g., ['dice', 'jaccard', 'accuracy'] |
240 | | - prediction_threshold: float = 0.5 # Probability/logit threshold for binary metrics |
241 | | - instance_iou_threshold: float = 0.5 # IoU threshold for instance matching metrics |
242 | | - # Neurite ERL evaluation via lib/em_erl. nerl_graph accepts an ERLGraph |
243 | | - # .npz or a BANIS/NISB-style NetworkX skeleton.pkl. |
244 | | - nerl_graph: Any = None |
245 | | - nerl_mask: Any = None |
246 | | - nerl_resolution: Optional[List[float]] = None |
247 | | - nerl_merge_threshold: int = 1 |
248 | | - nerl_chunk_num: int = 1 |
249 | | - nerl_skeleton_id_attribute: str = "id" |
250 | | - nerl_skeleton_position_attribute: str = "index_position" |
251 | | - nerl_skeleton_edge_length_attribute: str = "edge_length" |
252 | | - nerl_skeleton_position_order: str = "xyz" |
253 | | - nerl_prediction_position_order: Optional[str] = None |
254 | | - |
255 | | - |
256 | 160 | @dataclass |
257 | 161 | class InferenceConfig: |
258 | 162 | """Inference configuration. |
@@ -289,16 +193,10 @@ class InferenceConfig: |
289 | 193 | # Optional explicit intermediate prediction file (.h5). If set in test |
290 | 194 | # mode, pipeline loads this file directly and proceeds to top-level decoding. |
291 | 195 | tta_result_path: str = "" |
292 | | - # Path to pre-computed affinity prediction HDF5 (dataset "main"). |
293 | | - # When set, skips model inference — loads and decodes directly. |
294 | | - saved_prediction_path: str = "" |
295 | | - # Path to save decoded instance segmentation (separate from raw prediction). |
296 | | - decoding_path: str = "" |
297 | 196 | prediction_transform: PredictionTransformConfig = field( |
298 | 197 | default_factory=PredictionTransformConfig |
299 | 198 | ) |
300 | 199 | save_prediction: SavePredictionConfig = field(default_factory=SavePredictionConfig) |
301 | | - postprocessing: PostprocessingConfig = field(default_factory=PostprocessingConfig) |
302 | 200 | memory_cleanup: InferenceMemoryCleanupConfig = field( |
303 | 201 | default_factory=InferenceMemoryCleanupConfig |
304 | 202 | ) |
|
0 commit comments