Shortcuts

DBModuleLoss

class mmocr.models.textdet.DBModuleLoss(loss_prob={'type': 'MaskedBalancedBCEWithLogitsLoss'}, loss_thr={'beta': 0, 'type': 'MaskedSmoothL1Loss'}, loss_db={'type': 'MaskedDiceLoss'}, weight_prob=5.0, weight_thr=10.0, shrink_ratio=0.4, thr_min=0.3, thr_max=0.7, min_sidelength=8)[source]

The class for implementing DBNet loss.

This is partially adapted from https://github.com/MhLiao/DB.

Parameters
  • loss_prob (dict) – The loss config for probability map. Defaults to dict(type=’MaskedBalancedBCEWithLogitsLoss’).

  • loss_thr (dict) – The loss config for threshold map. Defaults to dict(type=’MaskedSmoothL1Loss’, beta=0).

  • loss_db (dict) – The loss config for binary map. Defaults to dict(type=’MaskedDiceLoss’).

  • weight_prob (float) – The weight of probability map loss. Denoted as \(\alpha\) in paper. Defaults to 5.

  • weight_thr (float) – The weight of threshold map loss. Denoted as \(\beta\) in paper. Defaults to 10.

  • shrink_ratio (float) – The ratio of shrunk text region. Defaults to 0.4.

  • thr_min (float) – The minimum threshold map value. Defaults to 0.3.

  • thr_max (float) – The maximum threshold map value. Defaults to 0.7.

  • min_sidelength (int or float) – The minimum sidelength of the minimum rotated rectangle around any text region. Defaults to 8.

Return type

None

forward(preds, data_samples)[source]

Compute DBNet loss.

Parameters
  • preds (tuple(tensor)) – Raw predictions from model, containing prob_logits, thr_map and binary_map. Each is a tensor of shape \((N, H, W)\).

  • data_samples (list[TextDetDataSample]) – The data samples.

Returns

The dict for dbnet losses with loss_prob, loss_db and loss_thr.

Return type

results(dict)

get_targets(data_samples)[source]

Generate loss targets from data samples.

Parameters

data_samples (list(TextDetDataSample)) – Ground truth data samples.

Returns

A tuple of four tensors as DBNet targets.

Return type

tuple

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.