Home

Awesome

Self-Supervised Learning with Vision Transformers

By Zhenda Xie*, Yutong Lin*, Zhuliang Yao, Zheng Zhang, Qi Dai, Yue Cao and Han Hu

This repo is the official implementation of "Self-Supervised Learning with Swin Transformers".

A important feature of this codebase is to include Swin Transformer as one of the backbones, such that we can evaluate the transferring performance of the learnt representations on down-stream tasks of object detection and semantic segmentation. This evaluation is usually not included in previous works due to the use of ViT/DeiT, which has not been well tamed for down-stream tasks.

It currently includes code and models for the following tasks:

Self-Supervised Learning and Linear Evaluation: Included in this repo. See get_started.md for a quick start.

Transferring Performance on Object Detection/Instance Segmentation: See Swin Transformer for Object Detection.

Transferring Performance on Semantic Segmentation: See Swin Transformer for Semantic Segmentation.

Highlights

Updates

05/13/2021

  1. Self-Supervised models with DeiT-Small on ImageNet-1K (MoBY-DeiT-Small-300Ep-Pretrained, MoBY-DeiT-Small-300Ep-Linear) are provided.
  2. The supporting code and config for self-supervised learning with DeiT-Small are provided.

05/11/2021

Initial Commits:

  1. Self-Supervised Pre-training models on ImageNet-1K (MoBY-Swin-T-300Ep-Pretrained, MoBY-Swin-T-300Ep-Linear) are provided.
  2. The supported code and models for self-supervised pre-training and ImageNet-1K linear evaluation, COCO object detection and ADE20K semantic segmentation are provided.

Introduction

MoBY: a self-supervised learning approach by combining MoCo v2 and BYOL

MoBY (the name MoBY stands for MoCo v2 with BYOL) is initially described in arxiv, which is a combination of two popular self-supervised learning approaches: MoCo v2 and BYOL. It inherits the momentum design, the key queue, and the contrastive loss used in MoCo v2, and inherits the asymmetric encoders, asymmetric data augmentations and the momentum scheduler in BYOL.

MoBY achieves reasonably high accuracy on ImageNet-1K linear evaluation: 72.8% and 75.3% top-1 accuracy using DeiT and Swin-T, respectively, by 300-epoch training. The performance is on par with recent works of MoCo v3 and DINO which adopt DeiT as the backbone, but with much lighter tricks.

teaser_moby

Swin Transformer as a backbone

Swin Transformer (the name Swin stands for Shifted window) is initially described in arxiv, which capably serves as a general-purpose backbone for computer vision. It achieves strong performance on COCO object detection (58.7 box AP and 51.1 mask AP on test-dev) and ADE20K semantic segmentation (53.5 mIoU on val), surpassing previous models by a large margin.

We involve Swin Transformer as one of backbones to evaluate the transferring performance on down-stream tasks such as object detection. This differentiate this codebase with other approaches studying SSL on Transformer architectures.

ImageNet-1K linear evaluation

MethodArchitectureEpochsParamsFLOPsimg/sTop-1 AccuracyPre-trained CheckpointLinear Checkpoint
SupervisedSwin-T30028M4.5G755.281.2Here
MoBYSwin-T10028M4.5G755.270.9TBA
MoBY<sup>1</sup>Swin-T10028M4.5G755.272.0TBA
MoBYDeiT-S30022M4.6G940.472.8GoogleDrive/GitHub/BaiduGoogleDrive/GitHub/Baidu
MoBYSwin-T30028M4.5G755.275.3GoogleDrive/GitHub/BaiduGoogleDrive/GitHub/Baidu

Transferring to Downstream Tasks

COCO Object Detection (2017 val)

BackboneMethodModelSchd.box mAPmask mAPParamsFLOPs
Swin-TMask R-CNNSup.1x43.739.848M267G
Swin-TMask R-CNNMoBY1x43.639.648M267G
Swin-TMask R-CNNSup.3x46.041.648M267G
Swin-TMask R-CNNMoBY3x46.041.748M267G
Swin-TCascade Mask R-CNNSup.1x48.141.786M745G
Swin-TCascade Mask R-CNNMoBY1x48.141.586M745G
Swin-TCascade Mask R-CNNSup.3x50.443.786M745G
Swin-TCascade Mask R-CNNMoBY3x50.243.586M745G

ADE20K Semantic Segmentation (val)

BackboneMethodModelCrop SizeSchd.mIoUmIoU (ms+flip)ParamsFLOPs
Swin-TUPerNetSup.512x512160K44.5145.8160M945G
Swin-TUPerNetMoBY512x512160K44.0645.5860M945G

Citing MoBY and Swin

MoBY

@article{xie2021moby,
  title={Self-Supervised Learning with Swin Transformers}, 
  author={Zhenda Xie and Yutong Lin and Zhuliang Yao and Zheng Zhang and Qi Dai and Yue Cao and Han Hu},
  journal={arXiv preprint arXiv:2105.04553},
  year={2021}
}

Swin Transformer

@article{liu2021Swin,
  title={Swin Transformer: Hierarchical Vision Transformer using Shifted Windows},
  author={Liu, Ze and Lin, Yutong and Cao, Yue and Hu, Han and Wei, Yixuan and Zhang, Zheng and Lin, Stephen and Guo, Baining},
  journal={arXiv preprint arXiv:2103.14030},
  year={2021}
}

Getting Started