Papers › LocalViT: Bringing Locality to Vision Transformers

LocalViT: Bringing Locality to Vision Transformers

12 Apr 2021arXiv:2104.05707archive 2025-07-28

Yawei Li, Kai Zhang, JieZhang Cao, Radu Timofte, Luc van Gool

We study how to introduce locality mechanisms into vision transformers. The transformer network originates from machine translation and is particularly good at modelling long-range dependencies within a long sequence. Although the global interaction between the token embeddings could be well modelled by the self-attention mechanism of transformers, what is lacking a locality mechanism for information exchange within a local region. Yet, locality is essential for images since it pertains to structures like lines, edges, shapes, and even objects. We add locality to vision transformers by introducing depth-wise convolution into the feed-forward network. This seemingly simple solution is inspired by the comparison between feed-forward networks and inverted residual blocks. The importance of locality mechanisms is validated in two ways: 1) A wide range of design choices (activation function, layer placement, expansion ratio) are available for incorporating locality mechanisms and all proper choices can lead to a performance gain over the baseline, and 2) The same locality mechanism is successfully applied to 4 vision transformers, which shows the generalization of the locality concept. In particular, for ImageNet2012 classification, the locality-enhanced transformers outperform the baselines DeiT-T and PVT-T by 2.6% and 3.1% with a negligible increase in the number of parameters and computational effort. Code is available at \url{https://github.com/ofsoundof/LocalViT}.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2104.05707")

Code

Syntology Ran 3 of 6 code samples harvested from 1 repository linked to this paper; 3 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 6 samples from 1 repository, 3 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ofsoundof/LocalViT officialmentioned in papermentioned on GitHubpytorchMIT report
rishikksh20/LocalViT-pytorch mentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

6 samples harvested; 3 ran; 0 honoured the contract we drafted; 3 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
1ran · fixture could not drive it
3unverified

Licence: 0 of the 6 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from ofsoundof/LocalViT. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

flops_to_string ofsoundof/LocalViT/flops_counter.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · ad708b63b59159a6 · report
window_partition ofsoundof/LocalViT/models/swin_transformer.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · f9fd6241d935f07b · report
window_reverse ofsoundof/LocalViT/models/swin_transformer.py official repository ran · our draft was wrong MIT (permissive) · fb32094c6dbece71 · report
build_dataset ofsoundof/LocalViT/datasets.py official repository unverified MIT (permissive) · 9153241c4331eb1a · report
build_transform ofsoundof/LocalViT/datasets.py official repository unverified MIT (permissive) · 3bc74137ab36aa79 · report
params_to_string ofsoundof/LocalViT/flops_counter.py official repository unverified MIT (permissive) · ddea91f7dddc66e6 · report

Tasks

Image Classification

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification ImageNet LocalViT-S GFLOPs 4.6 #681 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-S Number of params 22.4M #681 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-S Top 1 Accuracy 80.8% #681 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-PVT GFLOPs 4.8 #847 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-PVT Number of params 13.5M #847 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-PVT Top 1 Accuracy 78.2% #847 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-TNT GFLOPs 1.4 #931 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-TNT Number of params 6.3M #931 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-TNT Top 1 Accuracy 75.9% #931 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T GFLOPs 1.3 #969 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T Number of params 5.9M #969 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T Top 1 Accuracy 74.8% #969 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T2T GFLOPs 1.2 #997 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T2T Number of params 4.3M #997 of 1060 Archive leaderboard report
Image Classification ImageNet LocalViT-T2T Top 1 Accuracy 72.5% #997 of 1060 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

ConvolutionLocalViT

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections