Abstract
Semantic segmentation using Fully Convolutional Networks (FCNs) often results in coarse, blurry object boundaries due to successive downsampling operations. This paper introduces a novel architecture that learns dense, high-dimensional pixel embeddings to capture semantic similarity. These embeddings are used to perform localized, boundary-aware filtering of segmentation predictions. By implementing this process as efficient, differentiable layers, the model can be trained end-to-end. Experimental results on PASCAL VOC 2012 demonstrate that this approach significantly sharpens segmentation masks and improves overall accuracy, both as a standalone module and in conjunction with Conditional Random Fields (CRFs).
Introduction: The Resolution Challenge in FCNs
Fully convolutional networks have revolutionized semantic segmentation by allowing end-to-end training for pixel-wise classification. However, a persistent challenge is the loss of spatial resolution. The repeated use of strided convolutions and pooling layers—essential for capturing global context—inevitably discards fine-grained details. Consequently, the resulting output masks are often "blobby," with poorly defined boundaries that bleed into the background.
To address this, researchers have traditionally turned to post-processing techniques like dense Conditional Random Fields (CRFs). While effective, CRFs typically rely on low-level features like color and spatial proximity. These handcrafted affinities often fail in complex scenarios; for instance, a person wearing a patterned shirt might be segmented into multiple parts because the RGB-based filter perceives the patterns as distinct objects. This paper proposes a different path: learning semantic pixel affinities directly from data to perform localized sharpening within the network itself.
Methodology: Learning Semantic Affinities
The core of the proposed method is a two-stream architecture. The first stream is a standard segmentation network (e.g., DeepLab) that produces coarse class scores. The second stream is an embeddings network that maps each pixel to a 64-dimensional vector.
Pairwise Embedding Loss
The embeddings are trained to represent semantic similarity. The authors employ a pairwise loss function over local windows (e.g., $9 \times 9$). For any pair of pixels within this window:
- If they belong to the same semantic class, the $L_1$ distance between their embedding vectors is minimized.
- If they belong to different classes, their distance is maximized.
This forces the network to learn a representation where pixels on the same object are clustered together in embedding space, while pixels across an object boundary are pushed apart.
Semantic Bilateral Filtering
Once the embeddings are learned, they are used to generate local weights for filtering. For a center pixel $i$, the weight for a neighboring pixel $j$ is calculated based on the distance between their embeddings $E_i$ and $E_j$. This is mathematically equivalent to a bilateral filter, but instead of using RGB color, it uses the deep-learned semantic embeddings. The final prediction for pixel $i$ is a weighted average of the raw predictions in its neighborhood.
Efficient Implementation
To make this process computationally feasible, the authors developed custom layers. Specifically, the im2dist layer computes pairwise distances efficiently by leveraging im2col transformations and matrix multiplications. This allows the sharpening operation to run at speeds comparable to standard convolutional layers, facilitating end-to-end training and real-time inference.
Key Insights
- Recursive Refinement: Because the filtering operation is implemented as a convolutional layer, it can be applied multiple times. Applying a $9 \times 9$ filter recursively (e.g., 7 times) effectively increases the receptive field of the sharpening process, allowing for smoother interior predictions and even sharper boundaries.
- End-to-End Trainability: The entire pipeline is differentiable. This means the global classification loss can backpropagate through the filtering layers to fine-tune the embeddings, ensuring they are optimized specifically for the task of semantic segmentation.
- Intermediate Supervision: To improve the robustness of the embeddings, the authors apply the pairwise loss at multiple intermediate layers of the embedding network (based on VGG-16). This multi-scale supervision helps the network learn both fine-grained and high-level semantic features.
Experimental Results
The method was evaluated on the PASCAL VOC 2012 dataset, with embeddings initially pre-trained on Microsoft COCO.
Quantitative Performance
The addition of learned embeddings provided a consistent boost to the DeepLab baseline. On the PASCAL VOC 2012 test set, the Intersection-over-Union (IoU) increased from 70.31% to 71.54% using a $9 \times 9$ embedding filter applied recursively. Notably, the method is complementary to CRFs; a combination of DeepLab, embeddings, and a dense CRF achieved 74.00% IoU, surpassing the DeepLab+CRF baseline of 73.60%.
Qualitative Analysis
Visual inspections confirm the quantitative gains. As shown in the comparison below, the embedding-augmented network produces masks that are significantly more aligned with object boundaries and less prone to "bleeding" errors.
The learned embeddings successfully ignore intra-object texture variations (like the patterns on a bicycle or the leaves of a plant) while remaining highly sensitive to the actual edges of the object.
Conclusion and Future Work
This research demonstrates that learning semantic affinities is a powerful alternative to handcrafted filters for sharpening DCNN outputs. By embedding this logic directly into the network architecture via efficient convolutional layers, the authors provide a modular and end-to-end trainable solution for the resolution problem in semantic segmentation. Future work could explore applying these dense embeddings to other boundary-sensitive tasks, such as instance segmentation or depth estimation, where localized, semantic-aware smoothing is equally critical.
Summary updated