Shortcuts

BaseTextDetPostProcessor

class mmocr.models.textdet.BaseTextDetPostProcessor(text_repr_type='poly', rescale_fields=None, train_cfg=None, test_cfg=None)[source]

Base postprocessor for text detection models.

Parameters
  • text_repr_type (str) – The boundary encoding type, ‘poly’ or ‘quad’. Defaults to ‘poly’.

  • rescale_fields (list[str], optional) – The bbox/polygon field names to be rescaled. If None, no rescaling will be performed.

  • train_cfg (dict, optional) – The parameters to be passed to self.get_text_instances in training. Defaults to None.

  • test_cfg (dict, optional) – The parameters to be passed to self.get_text_instances in testing. Defaults to None.

Return type

None

get_text_instances(pred_results, data_sample, **kwargs)[source]

Get text instance predictions of one image.

Parameters
  • pred_result (tuple(Tensor)) – Prediction results of an image.

  • data_sample (TextDetDataSample) – Datasample of an image.

  • **kwargs – Other parameters. Configurable via __init__.train_cfg and __init__.test_cfg.

  • pred_results (Union[torch.Tensor, List[torch.Tensor]]) –

Returns

A new DataSample with predictions filled in. The polygon/bbox results are usually saved in TextDetDataSample.pred_instances.polygons or TextDetDataSample.pred_instances.bboxes. The confidence scores are saved in TextDetDataSample.pred_instances.scores.

Return type

TextDetDataSample

poly_nms(polygons, scores, threshold)[source]

Non-maximum suppression for text detection.

Parameters
  • polygons (list[ndarray]) – List of polygons.

  • scores (list[float]) – List of scores.

  • threshold (float) – Threshold for NMS.

Returns

  • keep_polys (list[ndarray]): List of preserved polygons after NMS.

  • keep_scores (list[float]): List of preserved scores after NMS.

Return type

tuple(keep_polys, keep_scores)

rescale(results, scale_factor)[source]

Rescale results in results.pred_instances according to scale_factor, whose keys are defined in self.rescale_fields. Usually used to rescale bboxes and/or polygons.

Parameters
Returns

Prediction results with rescaled results.

Return type

TextDetDataSample

split_results(pred_results)[source]

Split batched tensor(s) along the first dimension pack split tensors into a list.

Parameters

pred_results (tensor or list[tensor]) – Raw result tensor(s) from detection head. Each tensor usually has the shape of (N, …)

Returns

N tensors if pred_results

is a tensor, or a list of N lists of tensors if pred_results is a list of tensors.

Return type

list[tensor] or list[list[tensor]]

Read the Docs v: dev-1.x
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.