mirror of https://github.com/open-mmlab/mmocr.git
[Config] Update satrn config (#1300)
* [Config] Add textrec_default_runtime * [Config] Add textrec_default_runtime * add vis hook * update satrn cfg * update * update Co-authored-by: gaotongxiao <gaotongxiao@gmail.com>pull/1296/head
parent
814b281c79
commit
6ca7404925
|
@ -0,0 +1,67 @@
|
||||||
|
file_client_args = dict(backend='disk')
|
||||||
|
|
||||||
|
dictionary = dict(
|
||||||
|
type='Dictionary',
|
||||||
|
dict_file='dicts/english_digits_symbols.txt',
|
||||||
|
with_padding=True,
|
||||||
|
with_unknown=True,
|
||||||
|
same_start_end=True,
|
||||||
|
with_start=True,
|
||||||
|
with_end=True)
|
||||||
|
|
||||||
|
model = dict(
|
||||||
|
type='SATRN',
|
||||||
|
backbone=dict(type='ShallowCNN', input_channels=3, hidden_dim=512),
|
||||||
|
encoder=dict(
|
||||||
|
type='SATRNEncoder',
|
||||||
|
n_layers=12,
|
||||||
|
n_head=8,
|
||||||
|
d_k=512 // 8,
|
||||||
|
d_v=512 // 8,
|
||||||
|
d_model=512,
|
||||||
|
n_position=100,
|
||||||
|
d_inner=512 * 4,
|
||||||
|
dropout=0.1),
|
||||||
|
decoder=dict(
|
||||||
|
type='NRTRDecoder',
|
||||||
|
n_layers=6,
|
||||||
|
d_embedding=512,
|
||||||
|
n_head=8,
|
||||||
|
d_model=512,
|
||||||
|
d_inner=512 * 4,
|
||||||
|
d_k=512 // 8,
|
||||||
|
d_v=512 // 8,
|
||||||
|
module_loss=dict(
|
||||||
|
type='CEModuleLoss', flatten=True, ignore_first_char=True),
|
||||||
|
dictionary=dictionary,
|
||||||
|
max_seq_len=25,
|
||||||
|
postprocessor=dict(type='AttentionPostprocessor')),
|
||||||
|
data_preprocessor=dict(
|
||||||
|
type='TextRecogDataPreprocessor',
|
||||||
|
mean=[123.675, 116.28, 103.53],
|
||||||
|
std=[58.395, 57.12, 57.375]))
|
||||||
|
|
||||||
|
train_pipeline = [
|
||||||
|
dict(
|
||||||
|
type='LoadImageFromFile',
|
||||||
|
file_client_args=file_client_args,
|
||||||
|
ignore_empty=True,
|
||||||
|
min_size=5),
|
||||||
|
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'))
|
||||||
|
]
|
||||||
|
|
||||||
|
# TODO Add Test Time Augmentation `MultiRotateAugOCR`
|
||||||
|
test_pipeline = [
|
||||||
|
dict(type='LoadImageFromFile', file_client_args=file_client_args),
|
||||||
|
dict(type='Resize', scale=(100, 32), keep_ratio=False),
|
||||||
|
# add loading annotation after ``Resize`` because ground truth
|
||||||
|
# does not need to do resize data transform
|
||||||
|
dict(type='LoadOCRAnnotations', with_text=True),
|
||||||
|
dict(
|
||||||
|
type='PackTextRecogInputs',
|
||||||
|
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
|
||||||
|
]
|
|
@ -17,9 +17,9 @@ Collections:
|
||||||
README: configs/textrecog/satrn/README.md
|
README: configs/textrecog/satrn/README.md
|
||||||
|
|
||||||
Models:
|
Models:
|
||||||
- Name: satrn_academic
|
- Name: satrn_shallow_5e_st_mj
|
||||||
In Collection: SATRN
|
In Collection: SATRN
|
||||||
Config: configs/textrecog/satrn/satrn_academic.py
|
Config: configs/textrecog/satrn/satrn_shallow_5e_st_mj.py
|
||||||
Metadata:
|
Metadata:
|
||||||
Training Data:
|
Training Data:
|
||||||
- SynthText
|
- SynthText
|
||||||
|
@ -51,9 +51,9 @@ Models:
|
||||||
word_acc: 90.6
|
word_acc: 90.6
|
||||||
Weights: https://download.openmmlab.com/mmocr/textrecog/satrn/satrn_academic_20211009-cb8b1580.pth
|
Weights: https://download.openmmlab.com/mmocr/textrecog/satrn/satrn_academic_20211009-cb8b1580.pth
|
||||||
|
|
||||||
- Name: satrn_small
|
- Name: satrn_shallow-small_5e_st_mj
|
||||||
In Collection: SATRN
|
In Collection: SATRN
|
||||||
Config: configs/textrecog/satrn/satrn_small.py
|
Config: configs/textrecog/satrn/satrn_shallow-small_5e_st_mj.py
|
||||||
Metadata:
|
Metadata:
|
||||||
Training Data:
|
Training Data:
|
||||||
- SynthText
|
- SynthText
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
dictionary = dict(
|
|
||||||
type='Dictionary',
|
|
||||||
dict_file='dicts/english_digits_symbols.txt',
|
|
||||||
with_padding=True,
|
|
||||||
with_unknown=True,
|
|
||||||
same_start_end=True,
|
|
||||||
with_start=True,
|
|
||||||
with_end=True)
|
|
||||||
|
|
||||||
model = dict(
|
|
||||||
type='SATRN',
|
|
||||||
backbone=dict(type='ShallowCNN'),
|
|
||||||
encoder=dict(type='SATRNEncoder'),
|
|
||||||
decoder=dict(
|
|
||||||
type='NRTRDecoder',
|
|
||||||
module_loss=dict(type='CEModuleLoss'),
|
|
||||||
dictionary=dictionary,
|
|
||||||
max_seq_len=40),
|
|
||||||
data_preprocessor=dict(
|
|
||||||
type='TextRecogDataPreprocessor',
|
|
||||||
mean=[123.675, 116.28, 103.53],
|
|
||||||
std=[58.395, 57.12, 57.375]))
|
|
|
@ -1,107 +0,0 @@
|
||||||
_base_ = [
|
|
||||||
'../../_base_/recog_datasets/mjsynth.py',
|
|
||||||
'../../_base_/recog_datasets/synthtext.py',
|
|
||||||
'../../_base_/recog_datasets/cute80.py',
|
|
||||||
'../../_base_/recog_datasets/iiit5k.py',
|
|
||||||
'../../_base_/recog_datasets/svt.py',
|
|
||||||
'../../_base_/recog_datasets/svtp.py',
|
|
||||||
'../../_base_/recog_datasets/icdar2013.py',
|
|
||||||
'../../_base_/recog_datasets/icdar2015.py',
|
|
||||||
'../../_base_/default_runtime.py',
|
|
||||||
'../../_base_/schedules/schedule_adam_step_5e.py',
|
|
||||||
'satrn.py',
|
|
||||||
]
|
|
||||||
|
|
||||||
# dataset settings
|
|
||||||
train_list = [_base_.mj_rec_train, _base_.st_rec_train]
|
|
||||||
test_list = [
|
|
||||||
_base_.cute80_rec_test, _base_.iiit5k_rec_test, _base_.svt_rec_test,
|
|
||||||
_base_.svtp_rec_test, _base_.ic13_rec_test, _base_.ic15_rec_test
|
|
||||||
]
|
|
||||||
file_client_args = dict(backend='disk')
|
|
||||||
default_hooks = dict(logger=dict(type='LoggerHook', interval=50))
|
|
||||||
|
|
||||||
# optimizer
|
|
||||||
optim_wrapper = dict(type='OptimWrapper', optimizer=dict(type='Adam', lr=3e-4))
|
|
||||||
|
|
||||||
model = dict(
|
|
||||||
type='SATRN',
|
|
||||||
backbone=dict(type='ShallowCNN', input_channels=3, hidden_dim=512),
|
|
||||||
encoder=dict(
|
|
||||||
type='SATRNEncoder',
|
|
||||||
n_layers=12,
|
|
||||||
n_head=8,
|
|
||||||
d_k=512 // 8,
|
|
||||||
d_v=512 // 8,
|
|
||||||
d_model=512,
|
|
||||||
n_position=100,
|
|
||||||
d_inner=512 * 4,
|
|
||||||
dropout=0.1),
|
|
||||||
decoder=dict(
|
|
||||||
type='NRTRDecoder',
|
|
||||||
n_layers=6,
|
|
||||||
d_embedding=512,
|
|
||||||
n_head=8,
|
|
||||||
d_model=512,
|
|
||||||
d_inner=512 * 4,
|
|
||||||
d_k=512 // 8,
|
|
||||||
d_v=512 // 8,
|
|
||||||
module_loss=dict(
|
|
||||||
type='CEModuleLoss', flatten=True, ignore_first_char=True),
|
|
||||||
max_seq_len=25,
|
|
||||||
postprocessor=dict(type='AttentionPostprocessor')))
|
|
||||||
|
|
||||||
train_pipeline = [
|
|
||||||
dict(
|
|
||||||
type='LoadImageFromFile',
|
|
||||||
file_client_args=file_client_args,
|
|
||||||
ignore_empty=True,
|
|
||||||
min_size=5),
|
|
||||||
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'))
|
|
||||||
]
|
|
||||||
|
|
||||||
# TODO Add Test Time Augmentation `MultiRotateAugOCR`
|
|
||||||
test_pipeline = [
|
|
||||||
dict(type='LoadImageFromFile', file_client_args=file_client_args),
|
|
||||||
dict(type='Resize', scale=(100, 32), keep_ratio=False),
|
|
||||||
# add loading annotation after ``Resize`` because ground truth
|
|
||||||
# does not need to do resize data transform
|
|
||||||
dict(type='LoadOCRAnnotations', with_text=True),
|
|
||||||
dict(
|
|
||||||
type='PackTextRecogInputs',
|
|
||||||
meta_keys=('img_path', 'ori_shape', 'img_shape', 'valid_ratio'))
|
|
||||||
]
|
|
||||||
|
|
||||||
train_dataloader = dict(
|
|
||||||
batch_size=64,
|
|
||||||
num_workers=8,
|
|
||||||
persistent_workers=True,
|
|
||||||
sampler=dict(type='DefaultSampler', shuffle=True),
|
|
||||||
dataset=dict(
|
|
||||||
type='ConcatDataset', datasets=train_list, pipeline=train_pipeline))
|
|
||||||
test_dataloader = dict(
|
|
||||||
batch_size=1,
|
|
||||||
num_workers=4,
|
|
||||||
persistent_workers=True,
|
|
||||||
drop_last=False,
|
|
||||||
sampler=dict(type='DefaultSampler', shuffle=False),
|
|
||||||
dataset=dict(
|
|
||||||
type='ConcatDataset', datasets=test_list, pipeline=test_pipeline))
|
|
||||||
val_dataloader = test_dataloader
|
|
||||||
|
|
||||||
val_evaluator = dict(
|
|
||||||
type='MultiDatasetsEvaluator',
|
|
||||||
metrics=[
|
|
||||||
dict(
|
|
||||||
type='WordMetric',
|
|
||||||
mode=['exact', 'ignore_case', 'ignore_case_symbol']),
|
|
||||||
dict(type='CharMetric')
|
|
||||||
],
|
|
||||||
dataset_prefixes=['CUTE80', 'IIIT5K', 'SVT', 'SVTP', 'IC13', 'IC15'])
|
|
||||||
test_evaluator = val_evaluator
|
|
||||||
|
|
||||||
visualizer = dict(type='TextRecogLocalVisualizer', name='visualizer')
|
|
|
@ -1,4 +1,4 @@
|
||||||
_base_ = ['satrn_academic.py']
|
_base_ = ['satrn_shallow_5e_st_mj.py']
|
||||||
|
|
||||||
model = dict(
|
model = dict(
|
||||||
backbone=dict(type='ShallowCNN', input_channels=3, hidden_dim=256),
|
backbone=dict(type='ShallowCNN', input_channels=3, hidden_dim=256),
|
|
@ -0,0 +1,45 @@
|
||||||
|
_base_ = [
|
||||||
|
'../../_base_/recog_datasets/mjsynth.py',
|
||||||
|
'../../_base_/recog_datasets/synthtext.py',
|
||||||
|
'../../_base_/recog_datasets/cute80.py',
|
||||||
|
'../../_base_/recog_datasets/iiit5k.py',
|
||||||
|
'../../_base_/recog_datasets/svt.py',
|
||||||
|
'../../_base_/recog_datasets/svtp.py',
|
||||||
|
'../../_base_/recog_datasets/icdar2013.py',
|
||||||
|
'../../_base_/recog_datasets/icdar2015.py',
|
||||||
|
'../../_base_/textrec_default_runtime.py',
|
||||||
|
'../../_base_/schedules/schedule_adam_step_5e.py',
|
||||||
|
'_base_satrn_shallow.py',
|
||||||
|
]
|
||||||
|
|
||||||
|
# dataset settings
|
||||||
|
train_list = [_base_.mj_rec_train, _base_.st_rec_train]
|
||||||
|
test_list = [
|
||||||
|
_base_.cute80_rec_test, _base_.iiit5k_rec_test, _base_.svt_rec_test,
|
||||||
|
_base_.svtp_rec_test, _base_.ic13_rec_test, _base_.ic15_rec_test
|
||||||
|
]
|
||||||
|
|
||||||
|
train_dataset = dict(
|
||||||
|
type='ConcatDataset', datasets=train_list, pipeline=_base_.train_pipeline)
|
||||||
|
test_dataset = dict(
|
||||||
|
type='ConcatDataset', datasets=test_list, pipeline=_base_.test_pipeline)
|
||||||
|
|
||||||
|
# optimizer
|
||||||
|
optim_wrapper = dict(type='OptimWrapper', optimizer=dict(type='Adam', lr=3e-4))
|
||||||
|
|
||||||
|
train_dataloader = dict(
|
||||||
|
batch_size=64,
|
||||||
|
num_workers=8,
|
||||||
|
persistent_workers=True,
|
||||||
|
sampler=dict(type='DefaultSampler', shuffle=True),
|
||||||
|
dataset=train_dataset)
|
||||||
|
|
||||||
|
test_dataloader = dict(
|
||||||
|
batch_size=1,
|
||||||
|
num_workers=4,
|
||||||
|
persistent_workers=True,
|
||||||
|
drop_last=False,
|
||||||
|
sampler=dict(type='DefaultSampler', shuffle=False),
|
||||||
|
dataset=test_dataset)
|
||||||
|
|
||||||
|
val_dataloader = test_dataloader
|
Loading…
Reference in New Issue