ncalab.models.applications.segmentation
Submodules
Classes
Model used for image segmentation. |
Package Contents
- class ncalab.models.applications.segmentation.SegmentationNCAModel(device: torch.device, num_image_channels: int = 3, num_hidden_channels: int = 16, num_classes: int = 1, fire_rate: float = 0.8, hidden_size: int = 128, num_learned_filters: int = 2, pad_noise: bool = False, filter_padding: Literal['zero', 'reflect', 'replicate', 'circular'] = 'circular', lambda_hidden: float = 0.001, **kwargs)
Bases:
ncalab.models.basicNCA.AbstractNCAModelModel used for image segmentation.
Uses Dice score as the default validation metric. Currently, only binary segmentation masks are supported.
- Parameters:
[torch.device] (device) – Compute device.
[int] (learned_filters) – Number of image channels. Defaults to 3.
[int] – Number of hidden channels. Defaults to 16.
[int] – Number of classes. Defaults to 1.
[float] (fire_rate) – NCA fire rate. Defaults to 0.8.
[int] – Number of neurons in hidden layer. Defaults to 128.
[int] – Number of learned filters. If 0, use sobel. Defaults to 2.
[bool] (pad_noise) – Whether to pad input images with noise. Defaults to True.
[str] (filter_padding) – Padding type to use. Might affect reliance on spatial cues. Defaults to “circular”.
- num_classes = 1
- metrics
- bce_loss
- dice_loss
- loss(pred: ncalab.prediction.Prediction, label: torch.Tensor) Dict[str, torch.Tensor]
Compute Dice loss.
- Parameters:
pred – Prediction.
label – Ground truth.
- Returns:
Dictionary of identifiers mapped to computed losses.
- _post_forward_step(x: torch.Tensor) torch.Tensor
- post_prediction(prediction: ncalab.prediction.Prediction) ncalab.prediction.Prediction