Skip to content
fn

mask2former_swin_small

→Mask2FormerForSemanticSegmentation
mask2former_swin_small(pretrained: bool | str = False, weights: Mask2FormerSwinSmallWeights | None = None, overrides: object = {})

Mask2Former with Swin-Small backbone (Cheng et al., CVPR 2022).

Builds a Mask2FormerForSemanticSegmentation with the Swin-Small backbone (embed_dim = 96, depths = (2, 2, 18, 2), num_heads = (3, 6, 12, 24)). Same transformer head as mask2former_swin_tiny; ADE20K validation mIoU of 51.3%.

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag; a tag string → that specific checkpoint.
weights(Mask2FormerSwinSmallWeights, optional, keyword - only)= None
Explicit weights enum member. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into Mask2FormerConfig.

Returns

Mask2FormerForSemanticSegmentation

Segmentation model with the Mask2Former-Swin-S configuration applied (or with overrides merged on top of it).

Examples

>>> import lucid
>>> from lucid.models.vision.mask2former import mask2former_swin_small
>>> model = mask2former_swin_small()
>>> x = lucid.randn(1, 3, 384, 384)
>>> out = model(x)
>>> out.logits.shape[1]
150

Used by 1