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)[源代码]

The class for implementing DBNet loss.

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

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

返回类型

None

forward(preds, data_samples)[源代码]

Compute DBNet loss.

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

返回

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

返回类型

results(dict)

get_targets(data_samples)[源代码]

Generate loss targets from data samples.

参数

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

返回

A tuple of four tensors as DBNet targets.

返回类型

tuple

Read the Docs v: dev-1.x
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.