ResNet¶
- class mmocr.models.textrecog.ResNet(in_channels, stem_channels, block_cfgs, arch_layers, arch_channels, strides, out_indices=None, plugins=None, init_cfg=[{'type': 'Xavier', 'layer': 'Conv2d'}, {'type': 'Constant', 'val': 1, 'layer': 'BatchNorm2d'}])[source]¶
- Parameters
in_channels (int) – Number of channels of input image tensor.
stem_channels (list[int]) – List of channels in each stem layer. E.g., [64, 128] stands for 64 and 128 channels in the first and second stem layers.
block_cfgs (dict) – Configs of block
arch_layers (list[int]) – List of Block number for each stage.
arch_channels (list[int]) – List of channels for each stage.
strides (Sequence[int] or Sequence[tuple]) – Strides of the first block of each stage.
out_indices (Sequence[int], optional) – Indices of output stages. If not specified, only the last stage will be returned.
plugins (dict, optional) – Configs of stage plugins
init_cfg (dict or list[dict], optional) – Initialization config dict.
- forward(x)[source]¶
Args: x (Tensor): Image tensor of shape \((N, 3, H, W)\).
- Returns
Feature tensor. It can be a list of feature outputs at specific layers if
out_indices
is specified.- Return type
Tensor or list[Tensor]
- Parameters
x (torch.Tensor) –
- forward_plugin(x, plugin_name)[source]¶
Forward tensor through plugin.
- Parameters
x (torch.Tensor) – Input tensor.
- Returns
Output tensor.
- Return type