Locality-Attending Vision Transformer

Sina Hajimiri, Farzad Beizaee, Fereshteh Shakeri, Christian Desrosiers, Ismail Ben Ayed +1 more
3/5/2026
cs.CV

Official code: sinahmr/LocAtViT (19 stars, MIT, last commit 2026-03-10).

Abstract

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/.

View on arXivView PDF

Code Implementations(1)

sinahmr/LocAtViTOfficial100%
MIT

PyTorch Implementation of LocAtViT in "Locality-Attending Vision Transformer" (ICLR 2026)

190Shell, PythonFeb 27, 20267 months agoMIT

Similar Papers

Cite this paper

@article{hajimiri2026localityattending,
  title  = {Locality-Attending Vision Transformer},
  author = {Sina Hajimiri and Farzad Beizaee and Fereshteh Shakeri and Christian Desrosiers and Ismail Ben Ayed and Jose Dolz},
  year   = {2026},
  eprint = {2603.04892},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.04892v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2603.04892.svg)](https://codeofpaper.com/paper/2603.04892)

Discussion