open-mmlab / mmocr

OpenMMLab Text Detection, Recognition and Understanding Toolbox
https://mmocr.readthedocs.io/en/dev-1.x/
Apache License 2.0
4.34k stars 749 forks source link

No cut up for ctc converter, bug or feature? #149

Closed techkang closed 3 years ago

techkang commented 3 years ago

If the data length after the CTC converter is larger than the input length of input and set flatten=True in CTCLoss, there will be an error when calculating CTC loss. So is it a bug or a feature for not doing cut up in CTCConverter?

jeffreykuang commented 3 years ago

thanks for your report. did you solve your problem?

techkang commented 3 years ago

I found this error because I change the backbone of CRNN and the output shape is B1637. I change the parameter of my backbone and the problem does not appear again so I close this issue. But the problem may appear again if one instance is extremely long.

cuhk-hbsun commented 3 years ago

Thanks for your feedback. For CTC loss, you can set zero_infinity=True in the config file to avoid the effect. Please see the official PyTorch doc or https://github.com/open-mmlab/mmocr/blob/main/mmocr/models/textrecog/losses/ctc_loss.py for the explanation.