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

rec_r45_abinet for export model #10892

Merged
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
2 changes: 1 addition & 1 deletion configs/rec/rec_r45_abinet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Global:
cal_metric_during_train: True
pretrained_model: ./pretrain_models/abinet_vl_pretrained
checkpoints:
save_inference_dir:
save_inference_dir: ./output/rec/r45_abinet/infer
use_visualdl: False
infer_img: doc/imgs_words_en/word_10.png
# for data or label process
Expand Down
8 changes: 6 additions & 2 deletions tools/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ def export_single_model(model,
]
model = to_static(model, input_spec=other_shape)
elif arch_config["algorithm"] == "ABINet":
if not input_shape:
input_shape = [3, 32, 128]
other_shape = [
paddle.static.InputSpec(
shape=[None, 3, 32, 128], dtype="float32"),
shape=[None] + input_shape, dtype="float32"),
]
# print([None, 3, 32, 128])
model = to_static(model, input_spec=other_shape)
elif arch_config["algorithm"] in ["NRTR", "SPIN", 'RFL']:
other_shape = [
Expand Down Expand Up @@ -270,6 +271,9 @@ def main():
"name"] != 'MultiHead':
input_shape = config["Eval"]["dataset"]["transforms"][-2][
'SVTRRecResizeImg']['image_shape']
elif arch_config["algorithm"].lower() == "ABINet".lower():
rec_rs = [c for c in config["Eval"]["dataset"]["transforms"] if 'ABINetRecResizeImg' in c]
input_shape = rec_rs[0]['ABINetRecResizeImg']['image_shape'] if rec_rs else None
else:
input_shape = None

Expand Down