Shortcuts

BaseRecognizer

class mmocr.models.textrecog.BaseRecognizer(data_preprocessor=None, init_cfg=None)[源代码]

Base class for recognizer.

参数
  • data_preprocessor (dict or ConfigDict, optional) – The pre-process config of BaseDataPreprocessor. it usually includes, pad_size_divisor, pad_value, mean and std.

  • init_cfg (dict or ConfigDict or List[dict], optional) – the config to control the initialization. Defaults to None.

abstract extract_feat(inputs)[源代码]

Extract features from images.

参数

inputs (torch.Tensor) –

返回类型

torch.Tensor

forward(inputs, data_samples=None, mode='tensor', **kwargs)[源代码]

The unified entry for a forward process in both training and test.

The method should accept three modes: “tensor”, “predict” and “loss”:

  • “tensor”: Forward the whole network and return tensor or tuple of

tensor without any post-processing, same as a common nn.Module. - “predict”: Forward and return the predictions, which are fully processed to a list of DetDataSample. - “loss”: Forward and return a dict of losses according to the given inputs and data samples.

Note that this method doesn’t handle neither back propagation nor optimizer updating, which are done in the train_step().

参数
  • inputs (torch.Tensor) – The input tensor with shape (N, C, …) in general.

  • data_samples (list[DetDataSample], optional) – The annotation data of every samples. Defaults to None.

  • mode (str) – Return what kind of value. Defaults to ‘tensor’.

返回

The return type depends on mode.

  • If mode="tensor", return a tensor or a tuple of tensor.

  • If mode="predict", return a list of DetDataSample.

  • If mode="loss", return a dict of tensor.

返回类型

Union[Dict[str, torch.Tensor], List[mmocr.structures.textrecog_data_sample.TextRecogDataSample], Tuple[torch.Tensor], torch.Tensor]

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

Calculate losses from a batch of inputs and data samples.

参数
返回类型

Union[dict, tuple]

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

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

参数
返回类型

List[mmocr.structures.textrecog_data_sample.TextRecogDataSample]

property with_backbone

whether the recognizer has a backbone

Type

bool

property with_decoder

whether the recognizer has a decoder

Type

bool

property with_encoder

whether the recognizer has an encoder

Type

bool

property with_preprocessor

whether the recognizer has a preprocessor

Type

bool

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.