RobustScannerFuser¶
- class mmocr.models.textrecog.RobustScannerFuser(dictionary, module_loss=None, postprocessor=None, hybrid_decoder={'type': 'SequenceAttentionDecoder'}, position_decoder={'type': 'PositionAttentionDecoder'}, max_seq_len=30, in_channels=[512, 512], dim=- 1, init_cfg=None)[source]¶
Decoder for RobustScanner.
- Parameters
dictionary (dict or
Dictionary
) – The config for Dictionary or the instance of Dictionary.module_loss (dict, optional) – Config to build module_loss. Defaults to None.
postprocessor (dict, optional) – Config to build postprocessor. Defaults to None.
hybrid_decoder (dict) – Config to build hybrid_decoder. Defaults to dict(type=’SequenceAttentionDecoder’).
position_decoder (dict) – Config to build position_decoder. Defaults to dict(type=’PositionAttentionDecoder’).
fuser (dict) – Config to build fuser. Defaults to dict(type=’RobustScannerFuser’).
max_seq_len (int) – Maximum sequence length. The sequence is usually generated from decoder. Defaults to 30.
in_channels (list[int]) – List of input channels. Defaults to [512, 512].
dim (int) – The dimension on which to split the input. Defaults to -1.
init_cfg (dict or list[dict], optional) – Initialization configs. Defaults to None.
- Return type
- forward_test(feat=None, out_enc=None, data_samples=None)[source]¶
Forward for testing.
- Parameters
feat (torch.Tensor, optional) – The feature map from backbone of shape \((N, E, H, W)\). Defaults to None.
out_enc (torch.Tensor, optional) – Encoder output. Defaults to None.
data_samples (Sequence[TextRecogDataSample]) – Batch of TextRecogDataSample, containing vaild_ratio information. Defaults to None.
- Returns
Character probabilities. of shape \((N, self.max_seq_len, C)\) where \(C\) is
num_classes
.- Return type
Tensor
- forward_train(feat=None, out_enc=None, data_samples=None)[source]¶
Forward for training.
- Parameters
feat (torch.Tensor, optional) – The feature map from backbone of shape \((N, E, H, W)\). Defaults to None.
out_enc (torch.Tensor, optional) – Encoder output. Defaults to None.
data_samples (Sequence[TextRecogDataSample]) – Batch of TextRecogDataSample, containing gt_text information. Defaults to None.
- Return type