RM Operation can equivalently convert ResNet to VGG, which is better for pruning; and can help RepVGG perform better when the depth is large.

Overview

RMNet: Equivalently Removing Residual Connection from Networks

This repository is the official implementation of "RMNet: Equivalently Removing Residual Connection from Networks".

Requirements

To install requirements:

pip install torch
pip install torchvision

Training

To train the models in the paper, run this command:

python train.py -a rmrep_69 --dist-url 'tcp://127.0.0.1:23333' --dist-backend 'nccl' --multiprocessing-distributed --world-size 1 --rank 0 --workers 32 [imagenet-folder with train and val folders]

Our Pre-trained Models

You can download pretrained models here:

Evaluation

To evaluate our pre-trained models trained on ImageNet, run:

python train.py -a rmrep_69 -e checkpoint/rmrep_69.pth.tar [imagenet-folder with train and val folders]

Results

Our model achieves the following performance on :

Help RepVGG achieve better performance even when the depth is large

Arch Top-1 Accuracy(%) Top-5 Accuracy(%) Train FLOPs(G) Test FLOPs(M)
RepVGG-21 72.508 90.840 2.4 2.1
RepVGG-21(RM 0.25) 72.590 90.924 2.1 2.1
RepVGG-37 74.408 91.900 4.4 4.0
RepVGG-37(RM 0.25) 74.478 91.892 3.9 4.0
RepVGG-69 74.526 92.182 8.6 7.7
RepVGG-69(RM 0.5) 75.088 92.144 6.5 7.7
RepVGG-133 70.912 89.788 16.8 15.1
RepVGG-133(RM 0.75) 74.560 92.000 10.6 15.1

Image Classification on ImageNet

Model name Top 1 Accuracy(%) Top 5 Accuracy(%)
RMNeXt 41x5_16 78.498 94.086
RMNeXt 50x5_32 79.076 94.444
RMNeXt 50x6_32 79.57 94.644
RMNeXt 101x6_16 80.07 94.918
RMNeXt 152x6_32 80.356 80.356

Citation

If you find this code useful, please cite the following paper:

@misc{meng2021rmnet,
      title={RMNet: Equivalently Removing Residual Connection from Networks}, 
      author={Fanxu Meng and Hao Cheng and Jiaxin Zhuang and Ke Li and Xing Sun},
      year={2021},
      eprint={2111.00687},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Contributing

Our code is based on RepVGG

Comments
  • RM operation on SEBlock?

    RM operation on SEBlock?

    I do not understand the principle of RM operation on SEBlock, why you concat the original input feature map with input feature plus SE output? just for plain network structure when deploying? Please explain my puzzle thx !!

    opened by ttjjmm 2
  • request about the default and pretrained mobilenetV2 model

    request about the default and pretrained mobilenetV2 model

    Hi, First of all, thank you for your insightful work! I want to use your work to speed up my own network with the backbone of mobilenetV2. My question is that in your train.py file, the default model is RepVGG-A0, is there a default model for mobilenetV2? Furthermore, could you please provide your pretrained mobilenetV2 as well? Many thanks in advance!

    opened by mwsunshine 1
  • For MobileNetV3

    For MobileNetV3

    Hi, thanks for your wonderful work! In your paper, RM model can improve the performance of MobileNetV2, but your work do not implement RM model on MobileNetV3. Why did you choose MobileNetV2 instead of MobileNetV3? MobileNetV3 is better than MobileNetV2. Moreover, I want to ask if I want to apply RM model to MobileNetV3, the implementation of RM in MobileNetV3 is similar to RM model in MobilNetV2? Thanks!

    opened by qdd1234 1
  • 关于如何slimming剪枝RM模型的问题

    关于如何slimming剪枝RM模型的问题

    您好 我阅读您的代码,有一些问题和疑惑,希望您可以抽出宝贵的时间进行解答,感谢。 按照我的理解mask 是把不重要的权重置零,.slimming是真正的实现channel pruning。 slimming network论文是通过cfg记录网络结构,然后进行剪枝。rm方法通过RM操作去除ResNet的残差连接,deploy()后,再直接对ResNet18进行剪枝。 我想知道rm后的resnet,如何进行slimming剪枝。因为rm-Resnet.depooy()是不好进行调用cfg。

    opened by E18301194 0
  • conv输出进入BN后有精度问题?

    conv输出进入BN后有精度问题?

    您好!我在做RM的时候发现,conv输出进入BN输出有精度问题?

            idconv1 = nn.Conv2d(self.in_planes, self.in_planes+self.mid_planes, kernel_size=3, stride=1, padding=1, bias=False).eval()
            idbn1 = nn.BatchNorm2d(self.in_planes+self.mid_planes).eval()
            # init dirac_ kernel weight, bias, mean var to idconv1
            nn.init.dirac_(idconv1.weight.data[:self.in_planes])
            bn_var_sqrt1 = torch.sqrt(self.running1.running_var + self.running1.eps)
            idbn1.weight.data[:self.in_planes] = bn_var_sqrt1
            idbn1.bias.data[:self.in_planes] = self.running1.running_mean
            idbn1.running_mean.data[:self.in_planes] = self.running1.running_mean
            idbn1.running_var.data[:self.in_planes] = self.running1.running_var
            # init conv1 to idconv1
            idconv1.weight.data[self.in_planes:] = self.conv1.weight.data
            idbn1.weight.data[self.in_planes:] = self.bn1.weight.data
            idbn1.bias.data[self.in_planes:] = self.bn1.bias.data
            idbn1.running_mean.data[self.in_planes:] = self.bn1.running_mean
            idbn1.running_var.data[self.in_planes:] = self.bn1.running_var
    

    图片 左边三conv2d输出结果,右边三batchnorm2d输出结果,其中conv2d输出为0的值在batchnorm2d中输出成一个很小的值(1.6642e-08),请问这是什么原因造成的?如何修改代码消除这种现象。

    opened by Serissa 2
Owner
null
Pretrained models for Jax/Flax: StyleGAN2, GPT2, VGG, ResNet.

Pretrained models for Jax/Flax: StyleGAN2, GPT2, VGG, ResNet.

Matthias Wright 169 Dec 26, 2022
Pretrained models for Jax/Haiku; MobileNet, ResNet, VGG, Xception.

Pre-trained image classification models for Jax/Haiku Jax/Haiku Applications are deep learning models that are made available alongside pre-trained we

Alper Baris CELIK 14 Dec 20, 2022
Simple ONNX operation generator. Simple Operation Generator for ONNX.

sog4onnx Simple ONNX operation generator. Simple Operation Generator for ONNX. https://github.com/PINTO0309/simple-onnx-processing-tools Key concept V

Katsuya Hyodo 6 May 15, 2022
RMNet: Equivalently Removing Residual Connection from Networks

RM Operation can equivalently convert ResNet to VGG, which is better for pruning; and can help RepVGG perform better when the depth is large.

null 8 Nov 4, 2021
Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in ONNX

ONNX msg_chn_wacv20 depth completion Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20 model in

Ibai Gorordo 19 Oct 22, 2022
Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model in Tensorflow Lite.

TFLite-msg_chn_wacv20-depth-completion Python script for performing depth completion from sparse depth and rgb images using the msg_chn_wacv20. model

Ibai Gorordo 2 Oct 4, 2021
Monocular Depth Estimation - Weighted-average prediction from multiple pre-trained depth estimation models

merged_depth runs (1) AdaBins, (2) DiverseDepth, (3) MiDaS, (4) SGDepth, and (5) Monodepth2, and calculates a weighted-average per-pixel absolute dept

Pranav 39 Nov 21, 2022
The implemention of Video Depth Estimation by Fusing Flow-to-Depth Proposals

Flow-to-depth (FDNet) video-depth-estimation This is the implementation of paper Video Depth Estimation by Fusing Flow-to-Depth Proposals Jiaxin Xie,

null 32 Jun 14, 2022
Monocular Depth Estimation Using Laplacian Pyramid-Based Depth Residuals

LapDepth-release This repository is a Pytorch implementation of the paper "Monocular Depth Estimation Using Laplacian Pyramid-Based Depth Residuals" M

Minsoo Song 205 Dec 30, 2022
Beyond Image to Depth: Improving Depth Prediction using Echoes (CVPR 2021)

Beyond Image to Depth: Improving Depth Prediction using Echoes (CVPR 2021) Kranti Kumar Parida, Siddharth Srivastava, Gaurav Sharma. We address the pr

Kranti Kumar Parida 33 Jun 27, 2022
Light-weight network, depth estimation, knowledge distillation, real-time depth estimation, auxiliary data.

light-weight-depth-estimation Boosting Light-Weight Depth Estimation Via Knowledge Distillation, https://arxiv.org/abs/2105.06143 Junjie Hu, Chenyou F

Junjie Hu 13 Dec 10, 2022
Data-depth-inference - Data depth inference with python

Welcome! This readme will guide you through the use of the code in this reposito

Marco 3 Feb 8, 2022
(CVPR 2022 - oral) Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry

Multi-View Depth Estimation by Fusing Single-View Depth Probability with Multi-View Geometry Official implementation of the paper Multi-View Depth Est

Bae, Gwangbin 138 Dec 28, 2022
Multiple types of NN model optimization environments. It is possible to directly access the host PC GUI and the camera to verify the operation. Intel iHD GPU (iGPU) support. NVIDIA GPU (dGPU) support.

mtomo Multiple types of NN model optimization environments. It is possible to directly access the host PC GUI and the camera to verify the operation.

Katsuya Hyodo 24 Mar 2, 2022
Unofficial implementation of the Involution operation from CVPR 2021

involution_pytorch Unofficial PyTorch implementation of "Involution: Inverting the Inherence of Convolution for Visual Recognition" by Li et al. prese

Rishabh Anand 46 Dec 7, 2022
Unified file system operation experience for different backend

megfile - Megvii FILE library Docs: http://megvii-research.github.io/megfile megfile provides a silky operation experience with different backends (cu

MEGVII Research 76 Dec 14, 2022
Complete system for facial identity system. Include one-shot model, database operation, features visualization, monitoring

Complete system for facial identity system. Include one-shot model, database operation, features visualization, monitoring

null 2 Dec 28, 2021
Accelerated SMPL operation, commonly used in generate 3D human mesh, STAR included.

SMPL2 An enchanced and accelerated SMPL operation which commonly used in 3D human mesh generation. It takes a poses, shapes, cam_trans as inputs, outp

JinTian 20 Oct 17, 2022
Liecasadi - liecasadi implements Lie groups operation written in CasADi

liecasadi liecasadi implements Lie groups operation written in CasADi, mainly di

Artificial and Mechanical Intelligence 14 Nov 5, 2022