Skip to content
StackDecode
AI & ML Atlas
Deep LearningarchitectureAnimated walkthrough

Swin Transformer

A vision transformer using attention in shifted local windows.

The idea

Attention is computed only inside small windows, which keeps cost linear in image size. In alternate layers the windows are shifted so information crosses window borders. Patches are merged between stages, giving a hierarchy of feature maps like a CNN, which suits detection and segmentation.

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Split the image into patches and group them into windows.
  2. 2Apply self-attention inside each window.
  3. 3Shift the windows in the next layer so neighbours can interact.
  4. 4Merge patches to halve the resolution in the next stage.
1/4

Step by step

  1. 1Split the image into patches and group them into windows.
  2. 2Apply self-attention inside each window.
  3. 3Shift the windows in the next layer so neighbours can interact.
  4. 4Merge patches to halve the resolution in the next stage.

Where it is used

Backbone for detection, segmentation and video.

Watch out for

More complex to implement than a plain ViT.

Related