RecogTextDataset¶
- class mmocr.datasets.RecogTextDataset(ann_file='', backend_args=None, parser_cfg={'keys': ['filename', 'text'], 'type': 'LineJsonParser'}, metainfo=None, data_root='', data_prefix={'img_path': ''}, filter_cfg=None, indices=None, serialize_data=True, pipeline=[], test_mode=False, lazy_init=False, max_refetch=1000)[源代码]¶
RecogTextDataset for text recognition.
The annotation format can be both in jsonl and txt. If the annotation file is in jsonl format, it should be a list of dicts. If the annotation file is in txt format, it should be a list of lines.
The annotation formats are shown as follows. - txt format .. code-block:: none
test_img1.jpg OpenMMLabtest_img2.jpg MMOCRjsonl format
``{"filename": "test_img1.jpg", "text": "OpenMMLab"}`` ``{"filename": "test_img2.jpg", "text": "MMOCR"}``- 参数
ann_file (str) – Annotation file path. Defaults to ‘’.
backend_args (dict, optional) – Arguments to instantiate the prefix of uri corresponding backend. Defaults to None.
parse_cfg (dict, optional) – Config of parser for parsing annotations. Use
LineJsonParserwhen the annotation file is in jsonl format with keys offilenameandtext. The keys in parse_cfg should be consistent with the keys in jsonl annotations. The first key in parse_cfg should be the key of the path in jsonl annotations. The second key in parse_cfg should be the key of the text in jsonl UseLineStrParserwhen the annotation file is in txt format. Defaults todict(type='LineJsonParser', keys=['filename', 'text']).metainfo (dict, optional) – Meta information for dataset, such as class information. Defaults to None.
data_root (str) – The root directory for
data_prefixandann_file. Defaults to ‘’.data_prefix (dict) – Prefix for training data. Defaults to
dict(img_path='').filter_cfg (dict, optional) – Config for filter data. Defaults to None.
indices (int or Sequence[int], optional) – Support using first few data in annotation file to facilitate training/testing on a smaller dataset. Defaults to None which means using all
data_infos.serialize_data (bool, optional) – Whether to hold memory using serialized objects, when enabled, data loader workers can use shared RAM from master process instead of making a copy. Defaults to True.
pipeline (list, optional) – Processing pipeline. Defaults to [].
test_mode (bool, optional) –
test_mode=Truemeans in test phase. Defaults to False.lazy_init (bool, optional) – Whether to load annotation during instantiation. In some cases, such as visualization, only the meta information of the dataset is needed, which is not necessary to load annotation file.
RecogTextDatasetcan skip load annotations to save time by setlazy_init=False. Defaults to False.max_refetch (int, optional) – If
RecogTextDataset.prepare_dataget a None img. The maximum extra number of cycles to get a valid image. Defaults to 1000.