diff --git a/doc/doc_ch/kie.md b/doc/doc_ch/kie.md index b6f38a662f..26d2e560fc 100644 --- a/doc/doc_ch/kie.md +++ b/doc/doc_ch/kie.md @@ -438,7 +438,25 @@ inference/ser_vi_layoutxlm/ └── inference.pdmodel # inference模型的模型结构文件 ``` -RE任务的动转静过程适配中,敬请期待。 +信息抽取模型中的RE任务转inference模型步骤如下: + +``` bash +# -c 后面设置训练算法的yml配置文件 +# -o 配置可选参数 +# Architecture.Backbone.checkpoints 参数设置待转换的训练模型地址 +# Global.save_inference_dir 参数设置转换的模型将保存的地址 + +python3 tools/export_model.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=./output/re_vi_layoutxlm_xfund_zh/best_accuracy Global.save_inference_dir=./inference/re_vi_layoutxlm +``` + +转换成功后,在目录下有三个文件: + +``` +inference/re_vi_layoutxlm/ + ├── inference.pdiparams # inference模型的参数文件 + ├── inference.pdiparams.info # inference模型的参数信息,可忽略 + └── inference.pdmodel # inference模型的模型结构文件 +``` ## 4.2 模型推理 @@ -461,6 +479,26 @@ python3 kie/predict_kie_token_ser.py \ +VI-LayoutXLM模型基于RE任务进行推理,可以执行如下命令: + +```bash +cd ppstructure +python3 kie/predict_kie_token_ser_re.py \ + --kie_algorithm=LayoutXLM \ + --re_model_dir=../inference/re_vi_layoutxlm \ + --ser_model_dir=../inference/ser_vi_layoutxlm \ + --use_visual_backbone=False \ + --image_dir=./docs/kie/input/zh_val_42.jpg \ + --ser_dict_path=../train_data/XFUND/class_list_xfun.txt \ + --vis_font_path=../doc/fonts/simfang.ttf \ + --ocr_order_method="tb-yx" +``` + +RE可视化结果默认保存到`./output`文件夹里面,结果示例如下: + +
+ +
# 5. FAQ diff --git a/doc/doc_en/kie_en.md b/doc/doc_en/kie_en.md index 0c335a5ceb..cd1fffb27a 100644 --- a/doc/doc_en/kie_en.md +++ b/doc/doc_en/kie_en.md @@ -457,14 +457,31 @@ inference/ser_vi_layoutxlm/ └── inference.pdmodel # The program file of recognition ``` -Export of RE model is also in adaptation. +The RE model can be converted to the inference model using the following command. + +```bash +# -c Set the training algorithm yml configuration file. +# -o Set optional parameters. +# Architecture.Backbone.checkpoints Set the training model address. +# Global.save_inference_dir Set the address where the converted model will be saved. +python3 tools/export_model.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=./output/re_vi_layoutxlm_xfund_zh/best_accuracy Global.save_inference_dir=./inference/re_vi_layoutxlm +``` + +After the conversion is successful, there are three files in the model save directory: + +``` +inference/re_vi_layoutxlm/ + ├── inference.pdiparams # The parameter file of recognition inference model + ├── inference.pdiparams.info # The parameter information of recognition inference model, which can be ignored + └── inference.pdmodel # The program file of recognition +``` ## 4.2 Model inference The VI layoutxlm model performs reasoning based on the ser task, and can execute the following commands: -Using the following command to infer the VI-LayoutXLM model. +Using the following command to infer the VI-LayoutXLM SER model. ```bash cd ppstructure @@ -483,6 +500,26 @@ The visualized result will be saved in `./output`, which is shown as follows. +Using the following command to infer the VI-LayoutXLM RE model. + +```bash +cd ppstructure +python3 kie/predict_kie_token_ser_re.py \ + --kie_algorithm=LayoutXLM \ + --re_model_dir=../inference/re_vi_layoutxlm \ + --ser_model_dir=../inference/ser_vi_layoutxlm \ + --use_visual_backbone=False \ + --image_dir=./docs/kie/input/zh_val_42.jpg \ + --ser_dict_path=../train_data/XFUND/class_list_xfun.txt \ + --vis_font_path=../doc/fonts/simfang.ttf \ + --ocr_order_method="tb-yx" +``` + +The visualized result will be saved in `./output`, which is shown as follows. + +
+ +
# 5. FAQ