Shortcuts

BaseDecoder

class mmocr.models.textrecog.BaseDecoder(dictionary, module_loss=None, postprocessor=None, max_seq_len=40, init_cfg=None)[源代码]

Base decoder for text recognition, build the loss and postprocessor.

参数
  • dictionary (dict or Dictionary) – The config for Dictionary or the instance of Dictionary.

  • loss (dict, optional) – Config to build loss. Defaults to None.

  • postprocessor (dict, optional) – Config to build postprocessor. Defaults to None.

  • max_seq_len (int) – Maximum sequence length. The sequence is usually generated from decoder. Defaults to 40.

  • init_cfg (dict or list[dict], optional) – Initialization configs. Defaults to None.

  • module_loss (Optional[Dict]) –

返回类型

None

forward(feat=None, out_enc=None, data_samples=None)[源代码]

Decoder forward.

Args:
feat (Tensor, optional): Features from the backbone. Defaults

to None.

out_enc (Tensor, optional): Features from the encoder.

Defaults to None.

data_samples (list[TextRecogDataSample]): A list of N datasamples,

containing meta information and gold annotations for each of the images. Defaults to None.

返回

Features from decoder forward.

返回类型

Tensor

参数
forward_test(feat=None, out_enc=None, data_samples=None)[源代码]

Forward for testing.

参数
  • 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.

返回类型

torch.Tensor

forward_train(feat=None, out_enc=None, data_samples=None)[源代码]

Forward for training.

参数
  • 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.

返回类型

torch.Tensor

loss(feat=None, out_enc=None, data_samples=None)[源代码]

Calculate losses from a batch of inputs and data samples.

参数
  • feat (Tensor, optional) – Features from the backbone. Defaults to None.

  • out_enc (Tensor, optional) – Features from the encoder. Defaults to None.

  • data_samples (list[TextRecogDataSample], optional) – A list of N datasamples, containing meta information and gold annotations for each of the images. Defaults to None.

返回

A dictionary of loss components.

返回类型

dict[str, tensor]

predict(feat=None, out_enc=None, data_samples=None)[源代码]

Perform forward propagation of the decoder and postprocessor.

参数
  • feat (Tensor, optional) – Features from the backbone. Defaults to None.

  • out_enc (Tensor, optional) – Features from the encoder. Defaults to None.

  • data_samples (list[TextRecogDataSample]) – A list of N datasamples, containing meta information and gold annotations for each of the images. Defaults to None.

返回

A list of N datasamples of prediction results. Results are stored in pred_text.

返回类型

list[TextRecogDataSample]

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

Free document hosting provided by Read the Docs.