CRNNDecoder¶
- class mmocr.models.textrecog.CRNNDecoder(in_channels, dictionary, rnn_flag=False, module_loss=None, postprocessor=None, init_cfg={'layer': 'Conv2d', 'type': 'Xavier'}, **kwargs)[source]¶
Decoder for CRNN.
- Parameters
in_channels (int) – Number of input channels.
dictionary (dict or
Dictionary
) – The config for Dictionary or the instance of Dictionary.rnn_flag (bool) – Use RNN or CNN as the decoder. Defaults to False.
module_loss (dict, optional) – Config to build module_loss. Defaults to None.
postprocessor (dict, optional) – Config to build postprocessor. Defaults to None.
init_cfg (dict or list[dict], optional) – Initialization configs. Defaults to None.
- forward_test(feat=None, out_enc=None, data_samples=None)[source]¶
- Parameters
feat (Tensor) – A Tensor of shape \((N, C, 1, W)\).
out_enc (torch.Tensor, optional) – Encoder output. Defaults to None.
data_samples (list[TextRecogDataSample]) – Batch of TextRecogDataSample, containing
gt_text
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, out_enc=None, data_samples=None)[source]¶
- Parameters
feat (Tensor) – A Tensor of shape \((N, C, 1, W)\).
out_enc (torch.Tensor, optional) – Encoder output. Defaults to None.
data_samples (list[TextRecogDataSample], optional) – Batch of TextRecogDataSample, containing gt_text information. Defaults to None.
- Returns
The raw logit tensor. Shape \((N, W, C)\) where \(C\) is
num_classes
.- Return type
Tensor