diff --git a/configs/rec/PP-FormuaNet/rec_pp_formulanet_l.yml b/configs/rec/PP-FormuaNet/rec_pp_formulanet_l.yml index 6e454e667a..e7aa871ff2 100644 --- a/configs/rec/PP-FormuaNet/rec_pp_formulanet_l.yml +++ b/configs/rec/PP-FormuaNet/rec_pp_formulanet_l.yml @@ -18,9 +18,10 @@ Global: rec_char_dict_path: &rec_char_dict_path ppocr/utils/dict/unimernet_tokenizer max_new_tokens: &max_new_tokens 1024 input_size: &input_size [768, 768] - save_res_path: ./output/rec/predicts_unimernet_latexocr.txt + save_res_path: ./output/rec/predicts_pp_formulanet_l.txt allow_resize_largeImg: False start_ema: True + d2s_train_image_shape: [1,768,768] Optimizer: name: AdamW diff --git a/configs/rec/PP-FormuaNet/rec_pp_formulanet_s.yml b/configs/rec/PP-FormuaNet/rec_pp_formulanet_s.yml index 270af124a1..816b4ddaae 100644 --- a/configs/rec/PP-FormuaNet/rec_pp_formulanet_s.yml +++ b/configs/rec/PP-FormuaNet/rec_pp_formulanet_s.yml @@ -18,9 +18,10 @@ Global: rec_char_dict_path: &rec_char_dict_path ppocr/utils/dict/unimernet_tokenizer max_new_tokens: &max_new_tokens 1024 input_size: &input_size [384, 384] - save_res_path: ./output/rec/predicts_unimernet_latexocr.txt + save_res_path: ./output/rec/predicts_pp_formulanet_s.txt allow_resize_largeImg: False start_ema: True + d2s_train_image_shape: [1,384,384] Optimizer: name: AdamW diff --git a/configs/rec/rec_unimernet.yml b/configs/rec/rec_unimernet.yml index ead7145b76..9a04721c43 100644 --- a/configs/rec/rec_unimernet.yml +++ b/configs/rec/rec_unimernet.yml @@ -18,8 +18,9 @@ Global: rec_char_dict_path: &rec_char_dict_path ppocr/utils/dict/unimernet_tokenizer input_size: &input_size [192, 672] max_seq_len: &max_seq_len 1024 - save_res_path: ./output/rec/predicts_unimernet_plus_config_latexocr.txt + save_res_path: ./output/rec/predicts_unimernet.txt allow_resize_largeImg: False + d2s_train_image_shape: [1,192,672] Optimizer: name: AdamW diff --git a/ppocr/modeling/architectures/__init__.py b/ppocr/modeling/architectures/__init__.py index 14602f1e48..65b63187d2 100755 --- a/ppocr/modeling/architectures/__init__.py +++ b/ppocr/modeling/architectures/__init__.py @@ -50,6 +50,9 @@ def apply_to_static(model, config, logger): "SVTR", "SVTR_HGNet", "LaTeXOCR", + "UniMERNet", + "PP-FormulaNet-S", + "PP-FormulaNet-L", ] if config["Architecture"]["algorithm"] in ["Distillation"]: algo = list(config["Architecture"]["Models"].values())[0]["algorithm"] @@ -127,6 +130,16 @@ def apply_to_static(model, config, logger): InputSpec(shape=[None, None], dtype="float32"), ] ] + elif algo in ["UniMERNet", "PP-FormulaNet-S", "PP-FormulaNet-L"]: + specs = [ + [ + InputSpec( + [None] + config["Global"]["d2s_train_image_shape"], dtype="float32" + ), + InputSpec(shape=[None, None], dtype="float32"), + InputSpec(shape=[None, None], dtype="float32"), + ] + ] model = to_static(model, input_spec=specs) logger.info("Successfully to apply @to_static with specs: {}".format(specs)) return model