Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump model structure #304

Merged
merged 1 commit into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/rec/rec_icdar15_train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Global:
character_type: en
loss_type: ctc
distort: true
debug: false
reader_yml: ./configs/rec/rec_icdar15_reader.yml
pretrain_weights: ./pretrain_models/rec_mv3_none_bilstm_ctc/best_accuracy
checkpoints:
Expand Down
3 changes: 3 additions & 0 deletions tools/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __getattr__(self, key):

global_config = AttrDict()

default_config = {'Global': {'debug': False, }}


def load_config(file_path):
"""
Expand All @@ -85,6 +87,7 @@ def load_config(file_path):

Returns: global config
"""
merge_config(default_config)
_, ext = os.path.splitext(file_path)
assert ext in ['.yml', '.yaml'], "only support yaml files for now"
merge_config(yaml.load(open(file_path), Loader=yaml.Loader))
Expand Down
9 changes: 9 additions & 0 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def set_paddle_flags(**kwargs):
from ppocr.data.reader_main import reader_main
from ppocr.utils.save_load import init_model
from ppocr.utils.character import CharacterOps
from paddle.fluid.contrib.model_stat import summary


def main():
Expand Down Expand Up @@ -87,6 +88,14 @@ def main():
# compile program for multi-devices
train_compile_program = program.create_multi_devices_program(
train_program, train_opt_loss_name)

# dump mode structure
if config['Global']['debug']:
if 'Attention' in config['Head'].keys():
logger.warning('Does not suport dump attention...')
else:
summary(train_program)

init_model(config, train_program, exe)

train_info_dict = {'compile_program':train_compile_program,\
Expand Down