ABIModuleLoss¶
- class mmocr.models.textrecog.ABIModuleLoss(dictionary, max_seq_len=40, letter_case='unchanged', weight_vis=1.0, weight_lang=1.0, weight_fusion=1.0, **kwargs)[源代码]¶
Implementation of ABINet multiloss that allows mixing different types of losses with weights.
- 参数
dictionary (dict or
Dictionary
) – The config for Dictionary or the instance of Dictionary.max_seq_len (int) – Maximum sequence length. The sequence is usually generated from decoder. Defaults to 40.
letter_case (str) – There are three options to alter the letter cases of gt texts: - unchanged: Do not change gt texts. - upper: Convert gt texts into uppercase characters. - lower: Convert gt texts into lowercase characters. Usually, it only works for English characters. Defaults to ‘unchanged’.
weight_vis (float or int) – The weight of vision decoder loss. Defaults to 1.0.
weight_dec (float or int) – The weight of language decoder loss. Defaults to 1.0.
weight_fusion (float or int) – The weight of fuser (aligner) loss. Defaults to 1.0.
- 返回类型
- forward(outputs, data_samples)[源代码]¶
- 参数
outputs (dict) – The output dictionary with at least one of
out_vis
,out_langs
andout_fusers
specified.data_samples (list[TextRecogDataSample]) – List of
TextRecogDataSample
which are processed byget_target
.
- 返回
A loss dictionary with
loss_visual
,loss_lang
andloss_fusion
. Each should either be the loss tensor or None if the output of its corresponding module is not given.- 返回类型