Skip to content
fn

maskformer_resnet50

→MaskFormerForSemanticSegmentation
maskformer_resnet50(pretrained: bool | str = False, weights: MaskFormerResNet50Weights | None = None, overrides: object = {})

MaskFormer with ResNet-50 backbone (Cheng et al., NeurIPS 2021).

Builds a MaskFormerForSemanticSegmentation with the paper-cited ResNet-50 configuration: 100 segmentation queries, a 6-layer transformer decoder with d_model = 256, 8 attention heads, dim_feedforward = 2048, and a 256-channel FPN pixel decoder. Default targets ADE20K (150 semantic classes); reaches ADE20K validation mIoU of 44.5% (paper Table 3, MaskFormer-R50 row) — competitive with much heavier per-pixel baselines.

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag (MaskFormerResNet50Weights.ADE20K); a tag string → that specific checkpoint. Mutually exclusive with weights (which wins if both are given).
weights(MaskFormerResNet50Weights, optional, keyword - only)= None
Explicit weights enum member. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into MaskFormerConfig (num_classes, num_queries, d_model, num_decoder_layers, dropout, fpn_out_channels).

Returns

MaskFormerForSemanticSegmentation

Segmentation model with the MaskFormer-R50 configuration applied (or with overrides merged on top of it).

Notes

See Cheng et al., "Per-Pixel Classification is Not All You Need for Semantic Segmentation", NeurIPS 2021 (arXiv:2107.06278). The unification of semantic / instance / panoptic under mask classification is the conceptual key idea. Pretrained weights are converted from the facebook/maskformer-resnet50-ade checkpoint and hosted under lucid-dl/maskformer-resnet-50.

Examples

>>> import lucid
>>> from lucid.models.vision.maskformer import maskformer_resnet50
>>> model = maskformer_resnet50(num_classes=21)
>>> x = lucid.randn(1, 3, 512, 512)
>>> out = model(x)
>>> out.logits.shape[1]
21

Used by 1