mmocr/configs/textrecog/master/master_toy_dataset.py
2022-07-21 10:51:02 +08:00

79 lines
2.2 KiB
Python

_base_ = [
'../../_base_/default_runtime.py',
'../../_base_/recog_models/master.py',
'../../_base_/schedules/schedule_adam_step_12e.py',
]
default_hooks = dict(logger=dict(type='LoggerHook', interval=50), )
# dataset settings
dataset_type = 'OCRDataset'
data_root = 'test/data/recog_toy_dataset'
file_client_args = dict(backend='disk')
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=file_client_args),
dict(type='LoadOCRAnnotations', with_text=True),
dict(
type='RescaleToHeight',
height=48,
min_width=48,
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]
test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=file_client_args),
dict(
type='RescaleToHeight',
height=48,
min_width=48,
max_width=160,
width_divisor=16),
dict(type='PadToWidth', width=160),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
]
train_dataloader = dict(
batch_size=2,
num_workers=1,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_prefix=dict(img_path=None),
ann_file='label.json',
pipeline=train_pipeline))
val_dataloader = dict(
batch_size=2,
num_workers=1,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
data_root=data_root,
data_prefix=dict(img_path=None),
ann_file='label.json',
test_mode=True,
pipeline=test_pipeline))
test_dataloader = val_dataloader
val_evaluator = [
dict(
type='WordMetric', mode=['exact', 'ignore_case',
'ignore_case_symbol']),
dict(type='CharMetric')
]
test_evaluator = val_evaluator
visualizer = dict(type='TextRecogLocalVisualizer', name='visualizer')