Shortcuts

注意

您正在阅读 MMOCR 0.x 版本的文档。MMOCR 0.x 会在 2022 年末开始逐步停止维护,建议您及时升级到 MMOCR 1.0 版本,享受由 OpenMMLab 2.0 带来的更多新特性和更佳的性能表现。阅读 MMOCR 1.0 的维护计划发版日志代码文档 以了解更多。

Enable Blank Space Recognition

It is noteworthy that the LineStrParser should NOT be used to parse the annotation files containing multiple blank spaces (in file name or recognition transcriptions). The users have to convert the plain txt annotations to json lines to enable space recognition. For example:

% A plain txt annotation file that contains blank spaces
test/img 1.jpg Hello World!
test/img 2.jpg Hello Open MMLab!
test/img 3.jpg Hello MMOCR!

The LineStrParser will split the above annotation line to pieces (e.g. [‘test/img’, ‘1.jpg’, ‘Hello’, ‘World!’]) that cannot be matched to the keys (e.g. [‘filename’, ‘text’]). Therefore, we need to convert it to a json line format by json.dumps (check here to see how to dump jsonl), and then the annotation file will look like as follows:

% A json line annotation file that contains blank spaces
{"filename": "test/img 1.jpg", "text": "Hello World!"}
{"filename": "test/img 2.jpg", "text": "Hello Open MMLab!"}
{"filename": "test/img 3.jpg", "text": "Hello MMOCR!"}

After converting the annotation format, you just need to set the parser arguments as:

parser=dict(
    type='LineJsonParser',
    keys=['filename', 'text']))

Besides, you need to specify a dict that contains blank space to enable blank recognition. Particularly, MMOCR provides two built-in dicts DICT37 and DICT91 that contain blank space. For example, change the default dict_type in configs/_base_/recog_models/crnn.py to DICT37.

label_convertor = dict(
    type='CTCConvertor', dict_type='DICT37', with_unknown=False, lower=True) # ['DICT36', 'DICT37', 'DICT90', 'DICT91']
Read the Docs v: 0.x
Versions
latest
stable
dev-1.x
0.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.