|
|
1 dzień temu | |
|---|---|---|
| .. | ||
| README.md | 1 dzień temu | |
| metafile.yml | 1 dzień temu | |
| repvgg-A0_8xb32_in1k.py | 1 dzień temu | |
| repvgg-A0_deploy_in1k.py | 1 dzień temu | |
| repvgg-A1_8xb32_in1k.py | 1 dzień temu | |
| repvgg-A2_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B0_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B1_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B1g2_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B1g4_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B2_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B2g4_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B3_8xb32_in1k.py | 1 dzień temu | |
| repvgg-B3g4_8xb32_in1k.py | 1 dzień temu | |
| repvgg-D2se_8xb32_in1k.py | 1 dzień temu | |
RepVGG is a VGG-style convolutional architecture. It has the following advantages:
Predict image
from mmpretrain import inference_model, get_model
model = get_model('repvgg-A0_8xb32_in1k', pretrained=True)
model.backbone.switch_to_deploy()
predict = inference_model(model, 'demo/bird.JPEG')
print(predict['pred_class'])
print(predict['pred_score'])
Use the model
import torch
from mmpretrain import get_model
model = get_model('repvgg-A0_8xb32_in1k', pretrained=True)
inputs = torch.rand(1, 3, 224, 224)
out = model(inputs)
print(type(out))
# To extract features.
feats = model.extract_feat(inputs)
print(type(feats))
Train/Test Command
Prepare your dataset according to the docs.
Train:
python tools/train.py configs/repvgg/repvgg-A0_8xb32_in1k.py
Test:
python tools/test.py configs/repvgg/repvgg-A0_8xb32_in1k.py https://download.openmmlab.com/mmclassification/v0/repvgg/repvgg-A0_8xb32_in1k_20221213-60ae8e23.pth
Test with reparameterized model:
python tools/test.py configs/repvgg/repvgg-A0_8xb32_in1k.py repvgg_A0_deploy.pth --cfg-options model.backbone.deploy=True
Reparameterization
The checkpoints provided are all training-time models. Use the reparameterize tool to switch them to more efficient inference-time architecture, which not only has fewer parameters but also less calculations.
python tools/convert_models/reparameterize_model.py ${CFG_PATH} ${SRC_CKPT_PATH} ${TARGET_CKPT_PATH}
${CFG_PATH} is the config file, ${SRC_CKPT_PATH} is the source chenpoint file, ${TARGET_CKPT_PATH} is the target deploy weight file path.
To use reparameterized weights, the config file must switch to the deploy config files.
python tools/test.py ${deploy_cfg} ${deploy_checkpoint} --metrics accuracy
You can also use backbone.switch_to_deploy() to switch to the deploy mode in Python code. For example:
from mmpretrain.models import RepVGG
backbone = RepVGG(arch='A0')
backbone.switch_to_deploy()
| Model | Pretrain | Params (M) | Flops (G) | Top-1 (%) | Top-5 (%) | Config | Download |
|---|---|---|---|---|---|---|---|
repvgg-A0_8xb32_in1k |
From scratch | 8.31 | 1.36 | 72.37 | 90.56 | config | model | log |
repvgg-A1_8xb32_in1k |
From scratch | 12.79 | 2.36 | 74.23 | 91.80 | config | model | log |
repvgg-A2_8xb32_in1k |
From scratch | 25.50 | 5.12 | 76.49 | 93.09 | config | model | log |
repvgg-B0_8xb32_in1k |
From scratch | 3.42 | 15.82 | 75.27 | 92.21 | config | model | log |
repvgg-B1_8xb32_in1k |
From scratch | 51.83 | 11.81 | 78.19 | 94.04 | config | model | log |
repvgg-B1g2_8xb32_in1k |
From scratch | 41.36 | 8.81 | 77.87 | 93.99 | config | model | log |
repvgg-B1g4_8xb32_in1k |
From scratch | 36.13 | 7.30 | 77.81 | 93.77 | config | model | log |
repvgg-B2_8xb32_in1k |
From scratch | 80.32 | 18.37 | 78.58 | 94.23 | config | model | log |
repvgg-B2g4_8xb32_in1k |
From scratch | 55.78 | 11.33 | 79.44 | 94.72 | config | model | log |
repvgg-B3_8xb32_in1k |
From scratch | 110.96 | 26.21 | 80.58 | 95.33 | config | model | log |
repvgg-B3g4_8xb32_in1k |
From scratch | 75.63 | 16.06 | 80.26 | 95.15 | config | model | log |
repvgg-D2se_3rdparty_in1k* |
From scratch | 120.39 | 32.84 | 81.81 | 95.94 | config | model |
*Models with * are converted from the official repo. The config files of these models are only for inference. We haven't reproduce the training results.*
@inproceedings{ding2021repvgg,
title={Repvgg: Making vgg-style convnets great again},
author={Ding, Xiaohan and Zhang, Xiangyu and Ma, Ningning and Han, Jungong and Ding, Guiguang and Sun, Jian},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={13733--13742},
year={2021}
}