Locality-Attending Vision Transformer
Vision transformers have demonstrated remarkable success in classification by leveraging global self-attention to capture long-range dependencies. However, this same mechanism can obscure fine-grained spatial details crucial for tasks such as segmentation. In this work, we seek to enhance segmentation performance of vision transformers after standard image-level classification training. More specifically, we present a simple yet effective add-on that improves performance on segmentation tasks while retaining vision transformers' image-level recognition capabilities. In our approach, we modulate the self-attention with a learnable Gaussian kernel that biases the attention toward neighboring patches. We further refine the patch representations to learn better embeddings at patch positions. These modifications encourage tokens to focus on local surroundings and ensure meaningful representations at spatial positions, while still preserving the model's ability to incorporate global information. Experiments demonstrate the effectiveness of our modifications, evidenced by substantial segmentation gains on three benchmarks (e.g., over 6% and 4% on ADE20K for ViT Tiny and Base), without changing the training regime or sacrificing classification performance. The code is available at https://github.com/sinahmr/LocAtViT/.
69aa48cbc4f6edddcc6c864f
Sina Hajimiri
claimed_verified
2026-03-06T13:55:26.857Z
66bfafd19284c8209fd5c863
https://cdn-avatars.huggingface.co/v1/production/uploads/no-auth/fOe05JEwsFnLjoeec-_iZ.png
Sina Hajimiri
sinahmr
user
sinahmr
69aa48cbc4f6edddcc6c8650
Farzad Beizaee
69aa48cbc4f6edddcc6c8651
Fereshteh Shakeri
69aa48cbc4f6edddcc6c8652
Christian Desrosiers
69aa48cbc4f6edddcc6c8653
Ismail Ben Ayed
69aa48cbc4f6edddcc6c8654
Jose Dolz
Locality-Attending Vision Transformer
Vision transformers have demonstrated remarkable success in classification by leveraging global self-attention to capture long-range dependencies. However, this same mechanism can obscure fine-grained spatial details crucial for tasks such as segmentation. In this work, we seek to enhance segmentation performance of vision transformers after standard image-level classification training. More specifically, we present a simple yet effective add-on that improves performance on segmentation tasks while retaining vision transformers' image-level recognition capabilities. In our approach, we modulate the self-attention with a learnable Gaussian kernel that biases the attention toward neighboring patches. We further refine the patch representations to learn better embeddings at patch positions. These modifications encourage tokens to focus on local surroundings and ensure meaningful representations at spatial positions, while still preserving the model's ability to incorporate global information. Experiments demonstrate the effectiveness of our modifications, evidenced by substantial segmentation gains on three benchmarks (e.g., over 6% and 4% on ADE20K for ViT Tiny and Base), without changing the training regime or sacrificing classification performance. The code is available at https://github.com/sinahmr/LocAtViT/.
Vision transformers are enhanced for segmentation tasks through a Gaussian kernel modulation that improves local attention while maintaining classification performance.
vision transformers self-attention global self-attention segmentation Gaussian kernel attention modulation patch representations token focus spatial positions image-level classification local surroundings