Papers › CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows

CSWin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows

1 Jul 2021CVPR 2022 1arXiv:2107.00652archive 2025-07-28

Xiaoyi Dong, Jianmin Bao, Dongdong Chen, Weiming Zhang, Nenghai Yu, Lu Yuan, Dong Chen, Baining Guo

We present CSWin Transformer, an efficient and effective Transformer-based backbone for general-purpose vision tasks. A challenging issue in Transformer design is that global self-attention is very expensive to compute whereas local self-attention often limits the field of interactions of each token. To address this issue, we develop the Cross-Shaped Window self-attention mechanism for computing self-attention in the horizontal and vertical stripes in parallel that form a cross-shaped window, with each stripe obtained by splitting the input feature into stripes of equal width. We provide a mathematical analysis of the effect of the stripe width and vary the stripe width for different layers of the Transformer network which achieves strong modeling capability while limiting the computation cost. We also introduce Locally-enhanced Positional Encoding (LePE), which handles the local positional information better than existing encoding schemes. LePE naturally supports arbitrary input resolutions, and is thus especially effective and friendly for downstream tasks. Incorporated with these designs and a hierarchical structure, CSWin Transformer demonstrates competitive performance on common vision tasks. Specifically, it achieves 85.4\% Top-1 accuracy on ImageNet-1K without any extra training data or label, 53.9 box AP and 46.4 mask AP on the COCO detection task, and 52.2 mIOU on the ADE20K semantic segmentation task, surpassing previous state-of-the-art Swin Transformer backbone by +1.2, +2.0, +1.4, and +2.0 respectively under the similar FLOPs setting. By further pretraining on the larger dataset ImageNet-21K, we achieve 87.5% Top-1 accuracy on ImageNet-1K and high segmentation performance on ADE20K with 55.7 mIoU. The code and models are available at https://github.com/microsoft/CSWin-Transformer.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology 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="2107.00652")

Code

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

By repository: official repository: 4 samples from 1 repository, 0 ran; community (archive-listed): 2 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/CSWin-Transformer officialmentioned in papermentioned on GitHubpytorchMIT report
TJUdyk/CSWin-Transformer mentioned on GitHubpytorchMIT report
fogfog2/packnet mentioned on GitHubpytorch report
lyqcom/cswin-transformer mentioned on GitHubpytorch report
PaddlePaddle/PaddleClas paddleApache-2.0 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; 2 ran; 0 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

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

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 2 repositories linked to this paper, official or community; each sample names its own and says which. “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.

create_optimizer microsoft/CSWin-Transformer/finetune.py official repository unverified MIT (permissive) · 3b22aba5effad739 · report
load_img microsoft/CSWin-Transformer/labeled_memcached_dataset.py official repository unverified MIT (permissive) · 4d0c2350b24a4430 · report
train_epoch microsoft/CSWin-Transformer/finetune.py official repository unverified MIT (permissive) · e3b8df6691b9c559 · report
validate microsoft/CSWin-Transformer/finetune.py official repository unverified MIT (permissive) · e2a98c6a53ded11f · report
img2windows lyqcom/cswin-transformer/models/cswin.py community (archive-listed) ran · fixture could not drive it MIT (permissive) · 39b18f062e0cc6d9 · report
windows2img lyqcom/cswin-transformer/models/cswin.py community (archive-listed) ran · our draft was wrong MIT (permissive) · ab01fbfe58c75b08 · report

Tasks

Image ClassificationSemantic Segmentation

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification ImageNet CSWin-L (384 res,ImageNet-22k pretrain) GFLOPs 96.8 #84 of 1060 Archive leaderboard report
Image Classification ImageNet CSWin-L (384 res,ImageNet-22k pretrain) Number of params 173M #84 of 1060 Archive leaderboard report
Image Classification ImageNet CSWin-L (384 res,ImageNet-22k pretrain) Top 1 Accuracy 87.5% #84 of 1060 Archive leaderboard report
Semantic Segmentation ADE20K CSWin-L (UperNet, ImageNet-22k pretrain) Validation mIoU 55.70 #45 of 235 Archive leaderboard report
Semantic Segmentation ADE20K val CSWin-L (UperNet, ImageNet-22k pretrain) mIoU 55.7 #27 of 95 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

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxStochastic DepthSwin TransformerTransformer

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