https://github.com/amazon-science/exponential-moving-average-normalization

PyTorch implementation of EMAN for self-supervised and semi-supervised learning: https://arxiv.org/abs/2101.08482

https://github.com/amazon-science/exponential-moving-average-normalization

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.8%) to scientific vocabulary

Keywords

computer-vision normalization self-supervised-learning semi-supervised-learning
Last synced: 5 months ago · JSON representation

Repository

PyTorch implementation of EMAN for self-supervised and semi-supervised learning: https://arxiv.org/abs/2101.08482

Basic Info
  • Host: GitHub
  • Owner: amazon-science
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 71.3 KB
Statistics
  • Stars: 103
  • Watchers: 10
  • Forks: 13
  • Open Issues: 2
  • Releases: 0
Topics
computer-vision normalization self-supervised-learning semi-supervised-learning
Created over 4 years ago · Last pushed over 4 years ago
Metadata Files
Readme Contributing License Code of conduct

README.md

EMAN: Exponential Moving Average Normalization for Self-supervised and Semi-supervised Learning

This is a PyTorch implementation of the EMAN paper. It supports three popular self-supervised and semi-supervised learning techniques, i.e., MoCo, BYOL and FixMatch.

If you use the code/model/results of this repository please cite: @inproceedings{cai21eman, author = {Zhaowei Cai and Avinash Ravichandran and Subhransu Maji and Charless Fowlkes and Zhuowen Tu and Stefano Soatto}, title = {Exponential Moving Average Normalization for Self-supervised and Semi-supervised Learning}, booktitle = {CVPR}, Year = {2021} }

Install

First, install PyTorch and torchvision. We have tested on version of 1.7.1, but the other versions should also be working, e.g. 1.5.1.

bash $ conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch

Also install other dependencies.

bash $ pip install pandas faiss-gpu

Data Preparation

Install ImageNet dataset following the official PyTorch ImageNet training code, with the standard data folder structure for the torchvision datasets.ImageFolder. Please download the ImageNet index files for semi-supervised learning experiments. The file structure should look like:

bash $ tree data imagenet ├── train │ ├── class1 │ │ └── *.jpeg │ ├── class2 │ │ └── *.jpeg │ └── ... ├── val │ ├── class1 │ │ └── *.jpeg │ ├── class2 │ │ └── *.jpeg │ └── ... └── indexes └── *_index.csv

Training

To do self-supervised pre-training of MoCo-v2 with EMAN for 200 epochs, run: python main_moco.py \ --arch MoCoEMAN --backbone resnet50_encoder \ --epochs 200 --warmup-epoch 10 \ --moco-t 0.2 --cos \ --dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \ /path/to/imagenet

To do self-supervised pre-training of BYOL with EMAN for 200 epochs, run: python main_byol.py \ --arch BYOLEMAN --backbone resnet50_encoder \ --lr 1.8 -b 512 --wd 0.000001 \ --byol-m 0.98 \ --epochs 200 --cos --warmup-epoch 10 \ --dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \ /path/to/imagenet

To do semi-supervised training of FixMatch with EMAN for 100 epochs, run: python main_fixmatch.py \ --arch FixMatch --backbone resnet50_encoder \ --eman \ --lr 0.03 \ --epochs 100 --schedule 60 80 \ --warmup-epoch 5 \ --trainindex_x train_10p_index.csv --trainindex_u train_90p_index.csv \ --dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \ /path/to/imagenet

Linear Classification and Finetuning

With a pre-trained model, to train a supervised linear classifier on frozen features/weights (e.g. MoCo) on 10% imagenet, run: python main_lincls.py \ -a resnet50 \ --lr 30.0 \ --epochs 50 --schedule 30 40 \ --eval-freq 5 \ --trainindex train_10p_index.csv \ --model-prefix encoder_q \ --pretrained /path/to/model_best.pth.tar \ --dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \ /path/to/imagenet

To finetune the self-supervised pretrained model on 10% imagenet, with different learning rates for pretrained backbone and last classification layer, run: python main_cls.py \ -a resnet50 \ --lr 0.001 --lr-classifier 0.1 \ --epochs 50 --schedule 30 40 \ --eval-freq 5 \ --trainindex train_10p_index.csv \ --model-prefix encoder_q \ --self-pretrained /path/to/model_best.pth.tar \ --dist-url 'tcp://localhost:10001' --multiprocessing-distributed --world-size 1 --rank 0 \ /path/to/imagenet

For BYOL, change to --model-prefix online_net.backbone. For the best performance, follow the learning rate setting in Section 5.2 in the paper.

Models

Our pre-trained ResNet-50 models can be downloaded as following:

| name | epoch | acc@1% IN | acc@10% IN | acc@100% IN | model | | :---: | :---: | :---: | :---: | :---: | :---: | | MoCo-EMAN | 200 | 48.9 | 60.5 | 67.7 | download | | MoCo-EMAN | 800 | 55.4 | 64.0 | 70.1 | download | | MoCo-2X-EMAN | 200 | 56.8 | 65.7 | 72.3 | download | | BYOL-EMAN | 200 | 55.1 | 66.7 | 72.2 | download |

License

This project is under the CC-BY-NC 4.0 license. See LICENSE for details.

Owner

  • Name: Amazon Science
  • Login: amazon-science
  • Kind: organization

GitHub Events

Total
  • Watch event: 5
Last Year
  • Watch event: 5

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 4
  • Total pull requests: 1
  • Average time to close issues: about 22 hours
  • Average time to close pull requests: 7 days
  • Total issue authors: 3
  • Total pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • mingkai-zheng (2)
  • zhuhui123 (1)
  • gurdeepmaurya (1)
Pull Request Authors
  • zhaoweicai (1)
Top Labels
Issue Labels
Pull Request Labels