Shortcuts

RepVGG

class mmcls.models.RepVGG(arch, in_channels=3, base_channels=64, out_indices=(3,), strides=(2, 2, 2, 2), dilations=(1, 1, 1, 1), frozen_stages=- 1, conv_cfg=None, norm_cfg={'type': 'BN'}, act_cfg={'type': 'ReLU'}, with_cp=False, deploy=False, norm_eval=False, add_ppf=False, init_cfg=[{'type': 'Kaiming', 'layer': ['Conv2d']}, {'type': 'Constant', 'val': 1, 'layer': ['_BatchNorm', 'GroupNorm']}])[source]

RepVGG backbone.

A PyTorch impl of : RepVGG: Making VGG-style ConvNets Great Again

Parameters
  • arch (str | dict) –

    RepVGG architecture. If use string, choose from ‘A0’, ‘A1`’, ‘A2’, ‘B0’, ‘B1’, ‘B1g2’, ‘B1g4’, ‘B2’ , ‘B2g2’, ‘B2g4’, ‘B3’, ‘B3g2’, ‘B3g4’ or ‘D2se’. If use dict,

    it should have below keys:

    • num_blocks (Sequence[int]): Number of blocks in each stage.

    • width_factor (Sequence[float]): Width deflator in each stage.

    • group_layer_map (dict | None): RepVGG Block that declares the need to apply group convolution.

    • se_cfg (dict | None): Se Layer config.

    • stem_channels (int, optional): The stem channels, the final

      stem channels will be min(stem_channels, base_channels*width_factor[0]).

      If not set here, 64 is used by default in the code.

  • in_channels (int) – Number of input image channels. Default: 3.

  • base_channels (int) – Base channels of RepVGG backbone, work with width_factor together. Defaults to 64.

  • out_indices (Sequence[int]) – Output from which stages. Default: (3, ).

  • strides (Sequence[int]) – Strides of the first block of each stage. Default: (2, 2, 2, 2).

  • dilations (Sequence[int]) – Dilation of each stage. Default: (1, 1, 1, 1).

  • frozen_stages (int) – Stages to be frozen (all param fixed). -1 means not freezing any parameters. Default: -1.

  • conv_cfg (dict | None) – The config dict for conv layers. Default: None.

  • norm_cfg (dict) – The config dict for norm layers. Default: dict(type=’BN’).

  • act_cfg (dict) – Config dict for activation layer. Default: dict(type=’ReLU’).

  • with_cp (bool) – Use checkpoint or not. Using checkpoint will save some memory while slowing down the training speed. Default: False.

  • deploy (bool) – Whether to switch the model structure to deployment mode. Default: False.

  • norm_eval (bool) – Whether to set norm layers to eval mode, namely, freeze running stats (mean and var). Note: Effect on Batch Norm and its variants only. Default: False.

  • add_ppf (bool) – Whether to use the MTSPPF block. Default: False.

  • init_cfg (dict or list[dict], optional) – Initialization config dict.

forward(x)[source]

Forward computation.

Parameters

x (tensor | tuple[tensor]) – x could be a Torch.tensor or a tuple of Torch.tensor, containing input data for forward computation.

train(mode=True)[source]

Set module status before forward computation.

Parameters

mode (bool) – Whether it is train_mode or test_mode

Read the Docs v: latest
Versions
master
latest
1.x
dev-1.x
Downloads
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.