SoFTg reference¶
Classical segmentation is available with the base installation. Model, dataset, loss, training, prediction, and utility modules load on demand and require the softg extra where their dependencies are used.
Segment granules¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
sample_img |
Required | Two-dimensional intensity image. |
plate_scale |
Required | Positive spatial sampling in km/pixel. |
k |
0.165 |
Dynamic local-threshold parameter. |
lane_width_km |
150 |
Lane-width scale for morphology, in km. |
reconnect_ratio |
4.0 |
Morphological lane-reconnection control. |
lane_intensity_fraction |
0.4 |
Intensity fraction in the watershed stage. |
View implementation · Parameters and defaults generated from this checkout.
Returns (labels, seeds, skeleton) with the image shape. Read classical segmentation for units and processing stages.
Underlying classical helpers¶
Access these through SoFTg.granule_detection_lib.
Remove bright points¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
img |
Required | np.ndarray — Two-dimensional input image. |
plate_scale |
Required | float — Positive spatial sampling in km/pixel. |
bp_size_km |
200.0 |
float — Bright-point scale, in km. |
View implementation · Parameters and defaults generated from this checkout.
Compute a local dynamic threshold¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
img |
Required | np.ndarray — Two-dimensional input image. |
plate_scale |
Required | float — Positive spatial sampling in km/pixel. |
k |
Required | float — Dynamic local-threshold parameter. |
granule_size_km |
1250.0 |
float — Granule scale for the local threshold, in km. |
View implementation · Parameters and defaults generated from this checkout.
Clean and reconnect a lane mask¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
binary_mask |
Required | np.ndarray — Binary lane-mask input. |
plate_scale |
Required | float — Positive spatial sampling in km/pixel. |
lane_width_km |
150.0 |
float — Lane-width scale for morphology, in km. |
reconnect_ratio |
3.0 |
float — Morphological lane-reconnection control. |
View implementation · Parameters and defaults generated from this checkout.
UNet++ model¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
n_channels |
Required | Number of input image channels. |
n_classes |
Required | Number of output classes. |
scale |
1 |
Network filter-channel downscaling factor. |
bilinear |
True |
Requested upsampling option; the current UNet++ uses bilinear dense upsampling internally. |
dropout |
False |
Enable dropout in convolution blocks. |
View implementation · Parameters and defaults generated from this checkout.
For prediction, match the architecture expected by the checkpoint loader.
Load weights for prediction¶
| Parameter | Default | Annotation / meaning |
|---|---|---|
model_path |
Required | str — Path to architecture-compatible weights. |
device |
Required | torch.device — PyTorch device supplied by the caller. |
View implementation · Parameters and defaults generated from this checkout.
Constructs the bundled prediction architecture, loads compatible weights, sends the model to the supplied device, and returns it in evaluation mode. See checkpoint requirements.
Process an input file¶
Complete source signature
| Parameter | Default | Annotation / meaning |
|---|---|---|
input_path |
Required | Path to one FITS or NPY input file. |
model |
Required | Compatible PyTorch segmentation model. |
output_dir |
Required | Directory for saved prediction masks. |
tile_size |
Required | Tile side length in pixels. |
overlap |
Required | Tile overlap in pixels. |
threshold |
Required | Prediction probability threshold. |
min_size |
Required | Minimum feature/component size in pixels. |
preprocess |
Required | Enable enhancement; stacking/normalisation still apply if false. |
device |
Required | PyTorch device supplied by the caller. |
View implementation · Parameters and defaults generated from this checkout.
Reads FITS/NPY data, forms a single image (including median stacking for a cube), optionally enhances contrast, applies tiled inference and component cleanup, and writes masks. A three-dimensional input produces one mask from its median image.
Command-line modules¶
The ML guide documents data layout, supported weights, preprocessing, outputs, and reproducibility. The desktop SoFTg.label_tool requires the softg-gui extra and a graphical display.