Shortcuts

EncoderDecoderRecognizer

class mmocr.models.textrecog.EncoderDecoderRecognizer(preprocessor=None, backbone=None, encoder=None, decoder=None, data_preprocessor=None, init_cfg=None)[源代码]

Base class for encode-decode recognizer.

参数
  • preprocessor (dict, optional) – Config dict for preprocessor. Defaults to None.

  • backbone (dict, optional) – Backbone config. Defaults to None.

  • encoder (dict, optional) – Encoder config. If None, the output from backbone will be directly fed into decoder. Defaults to None.

  • decoder (dict, optional) – Decoder config. Defaults to None.

  • data_preprocessor (dict, optional) – Model preprocessing config for processing the input image data. Keys allowed are ``to_rgb``(bool), ``pad_size_divisor``(int), ``pad_value``(int or float), ``mean``(int or float) and ``std``(int or float). Preprcessing order: 1. to rgb; 2. normalization 3. pad. Defaults to None.

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

返回类型

None

extract_feat(inputs)[源代码]

Directly extract features from the backbone.

参数

inputs (torch.Tensor) –

返回类型

torch.Tensor

loss(inputs, data_samples, **kwargs)[源代码]

Calculate losses from a batch of inputs and data samples. :param inputs: Input images of shape (N, C, H, W).

Typically these should be mean centered and std scaled.

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

  • inputs (tensor) –

返回

A dictionary of loss components.

返回类型

dict[str, tensor]

predict(inputs, data_samples, **kwargs)[源代码]

Predict results from a batch of inputs and data samples with post- processing.

参数
  • inputs (torch.Tensor) – Image input tensor.

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

返回

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.