[CRNN] CRNN config

This commit is contained in:
liukuikun 2022-05-30 10:58:53 +00:00 committed by gaotongxiao
parent 38eef984c2
commit f1eebe9e34
2 changed files with 83 additions and 34 deletions

View File

@ -1,12 +1,18 @@
label_convertor = dict(
type='CTCConvertor', dict_type='DICT36', with_unknown=False, lower=True)
dictionary = dict(
type='Dictionary',
dict_file='dicts/lower_english_digits.txt',
with_padding=True)
model = dict(
type='CRNNNet',
preprocessor=None,
backbone=dict(type='VeryDeepVgg', leaky_relu=False, input_channels=1),
encoder=None,
decoder=dict(type='CRNNDecoder', in_channels=512, rnn_flag=True),
loss=dict(type='CTCLoss'),
label_convertor=label_convertor,
pretrained=None)
decoder=dict(
type='CRNNDecoder',
in_channels=512,
rnn_flag=True,
loss=dict(type='CTCLoss', letter_case='lower'),
postprocessor=dict(type='CTCPostProcessor')),
dictionary=dictionary,
preprocess_cfg=dict(mean=[127], std=[127]))

View File

@ -1,35 +1,78 @@
# training schedule for 1x
_base_ = [
'../../_base_/default_runtime.py', '../../_base_/recog_models/crnn.py',
'../../_base_/recog_pipelines/crnn_pipeline.py',
'../../_base_/recog_datasets/MJ_train.py',
'../../_base_/recog_datasets/academic_test.py',
'../../_base_/schedules/schedule_adadelta_5e.py'
'../../_base_/default_runtime.py',
'../../_base_/schedules/schedule_adadelta_5e.py',
'../../_base_/recog_models/crnn.py',
]
train_list = {{_base_.train_list}}
test_list = {{_base_.test_list}}
default_hooks = dict(logger=dict(type='LoggerHook', interval=50), )
train_pipeline = {{_base_.train_pipeline}}
test_pipeline = {{_base_.test_pipeline}}
# dataset settings
dataset_type = 'OCRDataset'
data_root = 'data/recog/'
file_client_args = dict(backend='disk')
data = dict(
samples_per_gpu=64,
workers_per_gpu=4,
val_dataloader=dict(samples_per_gpu=1),
test_dataloader=dict(samples_per_gpu=1),
train=dict(
type='UniformConcatDataset',
datasets=train_list,
pipeline=train_pipeline),
val=dict(
type='UniformConcatDataset',
datasets=test_list,
pipeline=test_pipeline),
test=dict(
type='UniformConcatDataset',
datasets=test_list,
train_pipeline = [
dict(
type='LoadImageFromFile',
color_type='grayscale',
file_client_args=file_client_args),
dict(type='LoadOCRAnnotations', with_text=True),
dict(type='Resize', scale=(100, 32), keep_ratio=False),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
]
test_pipeline = [
dict(
type='LoadImageFromFile',
color_type='grayscale',
file_client_args=file_client_args),
dict(
type='RescaleToHeight',
height=32,
min_width=32,
max_width=None,
width_divisor=16),
dict(
type='PackTextRecogInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio',
'instances'))
]
train_dataloader = dict(
batch_size=64,
num_workers=8,
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='train_label.json',
pipeline=train_pipeline))
val_dataloader = dict(
batch_size=1,
num_workers=4,
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='test_label.json',
test_mode=True,
pipeline=test_pipeline))
test_dataloader = val_dataloader
evaluation = dict(interval=1, metric='acc')
cudnn_benchmark = True
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')