Shortcuts

PANModuleLoss

class mmocr.models.textdet.PANModuleLoss(loss_text={'type': 'MaskedSquareDiceLoss'}, loss_kernel={'type': 'MaskedSquareDiceLoss'}, loss_embedding={'type': 'PANEmbLossV1'}, weight_text=1.0, weight_kernel=0.5, weight_embedding=0.25, ohem_ratio=3, shrink_ratio=(1.0, 0.5), max_shrink_dist=20, reduction='mean')[source]

The class for implementing PANet loss. This was partially adapted from https://github.com/whai362/pan_pp.pytorch and https://github.com/WenmuZhou/PAN.pytorch.

PANet: Efficient and Accurate Arbitrary- Shaped Text Detection with Pixel Aggregation Network.

Parameters
  • loss_text (dict) – dict(type=’MaskedSquareDiceLoss’).

  • loss_kernel (dict) – dict(type=’MaskedSquareDiceLoss’).

  • loss_embedding (dict) – dict(type=’PANEmbLossV1’).

  • weight_text (float) – The weight of text loss. Defaults to 1.

  • weight_kernel (float) – The weight of kernel loss. Defaults to 0.5.

  • weight_embedding (float) – The weight of embedding loss. Defaults to 0.25.

  • ohem_ratio (float) – The negative/positive ratio in ohem. Defaults to 3.

  • shrink_ratio (tuple[float]) – The ratio of shrinking kernel. Defaults to (1.0, 0.5).

  • max_shrink_dist (int or float) – The maximum shrinking distance. Defaults to 20.

  • reduction (str) – The way to reduce the loss. Available options are “mean” and “sum”. Defaults to ‘mean’.

Return type

None

forward(preds, data_samples)[source]

Compute PAN loss.

Parameters
  • preds (dict) – Raw predictions from model with shape \((N, C, H, W)\).

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

Returns

The dict for pan losses with loss_text, loss_kernel, loss_aggregation and loss_discrimination.

Return type

dict

get_targets(data_samples)[source]

Generate the gt targets for PANet.

Parameters
Returns

The output result dictionary.

Return type

results (dict)

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.