Skip to content

PyTorch implements `RepVGG: Making VGG-style ConvNets Great Again` paper.

License

Notifications You must be signed in to change notification settings

Lornatang/RepVGG-PyTorch

Repository files navigation

RepVGG-PyTorch

PyTorch implements RepVGG: Making VGG-style ConvNets Great Again paper.

ResNet-PyTorch

Overview

This repository contains an op-for-op PyTorch reimplementation of RepVGG: Making VGG-style ConvNets Great Again.

Table of contents

Download weights

Download datasets

Contains MNIST, CIFAR10&CIFAR100, TinyImageNet_200, MiniImageNet_1K, ImageNet_1K, Caltech101&Caltech256 and more etc.

Please refer to README.md in the data directory for the method of making a dataset.

How Test and Train

Both training and testing only need to modify yaml file.

Test RepVGG-A0_plain

# Multi-plain model convert to single plain model
python3 convert_plain_model.py --model_arch_name repvgg_a0 --i "./results/pretrained_models/RepVGG_A0-ImageNet_1K.pth.tar" --o "./results/pretrained_models/RepVGG_A0_plain-ImageNet_1K.pth.tar"
python3 test.py --config_path ./configs/test/REPVGG_A0_plain.yaml

Test RepVGG-A0

python3 test.py --config_path ./configs/test/REPVGG_A0.yaml

Train RepVGG-A0

python3 train.py --config_path ./configs/train/REPVGG_A0.yaml

Resume train RepVGG-A0

Modify the ./configs/train/REPVGG_A0.yaml file.

  • line 33: RESUMED_MODEL change to ./samples/RepVGG_A0-ImageNet_1K/epoch_xxx.pth.tar.
python3 train.py --config_path ./configs/train/RepVGG_A0.yaml

Result

Source of original paper results: https://arxiv.org/pdf/2101.03697v3.pdf)

In the following table, the top-x error value in () indicates the result of the project, and - indicates no test.

Model Dataset Top-1 Acc (val)
RepVGG-A0 ImageNet_1K 72.41(72.40)
RepVGG-A1 ImageNet_1K 74.46(74.48)
RepVGG-B1 ImageNet_1K 75.14(78.35)
RepVGG-A2 ImageNet_1K 76.48(76.47)
RepVGG-B1g4 ImageNet_1K 77.58(77.58)
RepVGG-B1g2 ImageNet_1K 77.78(77.78)
RepVGG-B1 ImageNet_1K 78.37(78.36)
RepVGG-B2g4 ImageNet_1K 78.50(78.50)
RepVGG-B2 ImageNet_1K 78.78(78.79)
# Download `RepVGG_A0_plain-ImageNet_1K.pth.tar` weights to `./results/pretrained_models`
# More detail see `README.md<Download weights>`
python3 ./inference.py 

Input:

Output:

Build `reg_vgg_a0` model successfully.
Load `reg_vgg_a0` model weights `/RepVGG-PyTorch/results/pretrained_models/RepVGG_A0_plain-ImageNet_1K.pth.tar` successfully.
tench, Tinca tinca                                                          (92.43%)
barracouta, snoek                                                           (6.45%)
armadillo                                                                   (0.46%)
mud turtle                                                                  (0.23%)
terrapin                                                                    (0.09%)

Contributing

If you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.

I look forward to seeing what the community does with these models!

Credit

RepVGG: Making VGG-style ConvNets Great Again

Xiaohan Ding, Xiangyu Zhang, Ningning Ma, Jungong Han, Guiguang Ding, Jian Sun

Abstract

We present a simple but powerful architecture of convolutional neural network, which has a VGG-like inference-time body composed of nothing but a stack of 3x3 convolution and ReLU, while the training-time model has a multi-branch topology. Such decoupling of the training-time and inference-time architecture is realized by a structural re-parameterization technique so that the model is named RepVGG. On ImageNet, RepVGG reaches over 80% top-1 accuracy, which is the first time for a plain model, to the best of our knowledge. On NVIDIA 1080Ti GPU, RepVGG models run 83% faster than ResNet-50 or 101% faster than ResNet-101 with higher accuracy and show favorable accuracy-speed trade-off compared to the state-of-the-art models like EfficientNet and RegNet. The code and trained models are available at this https URL.

[Paper] [Code]

@misc{ding2021repvgg,
      title={RepVGG: Making VGG-style ConvNets Great Again}, 
      author={Xiaohan Ding and Xiangyu Zhang and Ningning Ma and Jungong Han and Guiguang Ding and Jian Sun},
      year={2021},
      eprint={2101.03697},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

About

PyTorch implements `RepVGG: Making VGG-style ConvNets Great Again` paper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published