FCNForSemanticSegmentation
PretrainedModelFCNForSemanticSegmentation(config: FCNConfig)Fully Convolutional Network for semantic segmentation (Long et al., CVPR 2015).
The original deep-learning semantic segmentation architecture: a
classification backbone is repurposed as a fully convolutional
network by replacing fully-connected layers with 1x1 convolutions
and adding a final upsampling stage to recover input resolution.
In Lucid's implementation the backbone is a dilated ResNet
(layer3 dilation = 2, layer4 dilation = 4) so the deepest
feature map stays at stride 8 instead of stride 32, giving denser
spatial sampling without sacrificing the receptive field.
A primary FCN head produces num_classes logits from the C5
feature, and an auxiliary head on C4 stabilises optimisation
(used at training time only). Bilinear interpolation lifts both
heads to the input resolution.
Parameters
configFCNConfigfcn_resnet50 /
fcn_resnet101 for the standard variants.Attributes
configFCNConfigbackbone_DilatedResNetclassifier_FCNHeadnum_classes channels from the C5 feature.aux_classifier_FCNHeadNotes
See Long et al., "Fully Convolutional Networks for Semantic Segmentation", CVPR 2015 (arXiv:1411.4038). The bilinear upsampling at the end is equivalent to a learnable transpose convolution initialised to bilinear weights — but kept fixed in this modernised dilated-ResNet variant. Training loss is
with categorical cross-entropy summed over all pixels.
Examples
>>> import lucid
>>> from lucid.models.vision.fcn import fcn_resnet50
>>> model = fcn_resnet50()
>>> x = lucid.randn(1, 3, 512, 512)
>>> out = model(x)
>>> out.logits.shape # (B, num_classes, H, W)
(1, 21, 512, 512)Used by 2
Constructors
1Instance methods
1forward(x: Tensor, targets: Tensor | None = None)Run FCN forward pass.
Parameters
Returns
SemanticSegmentationOutputSemanticSegmentationOutput with logits (B, num_classes, H, W)