Skip to content
data

SemanticSegmentationOutput

extendsModelOutput
SemanticSegmentationOutput(logits: Tensor, loss: Tensor | None = None, hidden_states: tuple[Tensor, ...] | None = None)

Output of any {Family}ForSemanticSegmentation model.

Attributes

logitsTensor
Per-pixel class logits, shape (B, num_classes, H, W). Spatial resolution may match the input or be downsampled — call F.interpolate to upsample when needed.
loss(Tensor or None, optional)
Scalar segmentation loss (cross-entropy / Dice / per-class) when targets were supplied.
hidden_states(tuple[Tensor, ...] or None, optional)
Optional encoder / decoder feature maps.

Notes

Returned by FCN, U-Net, Attention U-Net, MaskFormer, and Mask2Former when used for semantic segmentation.

Examples

>>> import lucid
>>> from lucid.models import create_model
>>> model = create_model("fcn_resnet50", num_classes=21).eval()
>>> out = model(lucid.randn(1, 3, 224, 224))
>>> out.logits.shape              # (B, K, H, W) at input resolution
(1, 21, 224, 224)

Used by 6