spunet
SpUNet segmentation model.

Classes:
-
SparseUNetEncoderβSparse convolutional stem followed by stages that halve the resolution and run
SparseBasicBlockblocks. -
SparseUNetDecoderβMirror of
SparseUNetEncoder: each stage inverse-convolves, concatenates its skip, and runs residual blocks. -
SparseUNetSegmentationβSpUNet segmentation model, a sparse residual U-Net in the spirit of
SparseUNetEncoder [source] ΒΆ
SparseUNetEncoder(
in_channels: int,
stem_channels: int = 32,
channels: Sequence[int] = (32, 64, 128, 256),
depths: Sequence[int] = (2, 3, 4, 6),
stem_kernel_size: int = 5,
kernel_size: int = 3,
spatial_padding: int = 96,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: Module
Sparse convolutional stem followed by stages that halve the resolution and run SparseBasicBlock blocks.
The stem output and every stage output but the last are returned as decoder skips.
SparseUNetDecoder [source] ΒΆ
SparseUNetDecoder(
in_channels: int,
skip_channels: Sequence[int],
channels: Sequence[int],
depths: Sequence[int],
kernel_size: int = 3,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: Module
Mirror of SparseUNetEncoder: each stage inverse-convolves, concatenates its skip, and runs residual blocks.
Stages are built shallowest-first but run deepest-first, so channels and depths are read back-to-front.
SparseUNetSegmentation [source] ΒΆ
SparseUNetSegmentation(
in_channels: int,
num_classes: int,
*,
stem_channels: int = 32,
encoder_channels: Sequence[int] = (32, 64, 128, 256),
decoder_channels: Sequence[int] = (256, 128, 96, 96),
encoder_depths: Sequence[int] = (2, 3, 4, 6),
decoder_depths: Sequence[int] = (2, 2, 2, 2),
stem_kernel_size: int = 5,
kernel_size: int = 3,
spatial_padding: int = 96,
act: Union[str, Callable, None] = "relu",
act_kwargs: Optional[Dict[str, Any]] = None,
norm: Union[str, Callable, None] = "batch_norm",
norm_kwargs: Optional[Dict[str, Any]] = None,
)
Bases: SemanticSegmentationModel
SpUNet segmentation model, a sparse residual U-Net in the spirit of 4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural Networks by Christopher Choy, JunYoung Gwak, Silvio Savarese.
Voxelized coordinates enter a sparse convolutional stem, then a symmetric encoder-decoder of submanifold residual blocks with skip connections. The head runs on the full-resolution decoder output, whose rows stay aligned with the input points.
Parameters:
-
in_channels(int) βNumber of input feature channels. Positions are used as features when
xisNone. -
num_classes(int) βNumber of output classes. \(0\) replaces the head with
nn.Identity. -
stem_channels(int, default:32) βNumber of channels of the stem, also the width of the shallowest skip.
-
encoder_channels(Sequence[int], default:(32, 64, 128, 256)) βFeature width of every encoder stage.
-
decoder_channels(Sequence[int], default:(256, 128, 96, 96)) βFeature width of every decoder stage, deepest first.
-
encoder_depths(Sequence[int], default:(2, 3, 4, 6)) βNumber of residual blocks per encoder stage.
-
decoder_depths(Sequence[int], default:(2, 2, 2, 2)) βNumber of residual blocks per decoder stage, aligned with
decoder_channels. -
stem_kernel_size(int, default:5) βKernel size of the stem convolution.
-
kernel_size(int, default:3) βKernel size of the residual convolutions.
-
spatial_padding(int, default:96) βPadding added to the sparse spatial shape, so that voxel indices stay in range.
-
act(Union[str, Callable, None], default:'relu') βActivation function.
-
act_kwargs(Optional[Dict[str, Any]], default:None) βKeyword arguments for the activation function.
-
norm(Union[str, Callable, None], default:'batch_norm') βNormalization function.
-
norm_kwargs(Optional[Dict[str, Any]], default:None) βKeyword arguments for the normalization function.
Methods:
-
configure_encoderβBuild the sparse encoder producing the bottleneck features and the per-stage skips.
-
configure_decoderβBuild the sparse decoder upsampling the bottleneck back to full resolution.
Attributes:
-
num_features(int) βChannel count \(C\) of the full-resolution decoder features entering the head.
num_features property ΒΆ
Channel count \(C\) of the full-resolution decoder features entering the head.
configure_encoder [source] ΒΆ
configure_encoder() -> SparseUNetEncoder
Build the sparse encoder producing the bottleneck features and the per-stage skips.
configure_decoder [source] ΒΆ
configure_decoder() -> SparseUNetDecoder
Build the sparse decoder upsampling the bottleneck back to full resolution.