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')[源代码]¶
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.
- 参数
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’.
- 返回类型
- forward(preds, data_samples)[源代码]¶
Compute PAN loss.
- 参数
preds (dict) – Raw predictions from model with shape \((N, C, H, W)\).
data_samples (list[TextDetDataSample]) – The data samples.
- 返回
The dict for pan losses with loss_text, loss_kernel, loss_aggregation and loss_discrimination.
- 返回类型
- get_targets(data_samples)[源代码]¶
Generate the gt targets for PANet.
- 参数
results (dict) – The input result dictionary.
data_samples (Sequence[mmocr.structures.textdet_data_sample.TextDetDataSample]) –
- 返回
The output result dictionary.
- 返回类型
results (dict)