From f9e1389fe4e9b1d7660eaa1f92c4f2d07537a3b8 Mon Sep 17 00:00:00 2001 From: zhangzelun Date: Tue, 27 May 2025 06:05:14 +0000 Subject: [PATCH] adapt text det train cmds --- .../module_usage/seal_text_detection.en.md | 16 +++++++++------ .../module_usage/seal_text_detection.md | 20 +++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/version3.x/module_usage/seal_text_detection.en.md b/docs/version3.x/module_usage/seal_text_detection.en.md index 736a3f464ed..b79c8aac326 100644 --- a/docs/version3.x/module_usage/seal_text_detection.en.md +++ b/docs/version3.x/module_usage/seal_text_detection.en.md @@ -478,11 +478,15 @@ The training commands are as follows: ```bash # Single GPU training (default training method) python3 tools/train.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml \ - -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams + -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams \ + Train.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Train.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/train.txt \ + Eval.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Eval.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/val.txt # Multi-GPU training, specify GPU ids using the --gpus parameter -python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml \ - -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams +python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml \ + -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams \ + Train.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Train.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/train.txt \ + Eval.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Eval.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/val.txt ``` ### 4.3 Model Evaluation @@ -493,15 +497,15 @@ You can evaluate the trained weights, such as `output/xxx/xxx.pdparams`, using t # Make sure to set the pretrained_model path to the local path. If using a model that was trained and saved by yourself, be sure to modify the path and filename to {path/to/weights}/{model_name}. # Demo test set evaluation python3 tools/eval.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ -Global.pretrained_model=output/xxx/xxx.pdparams + Global.pretrained_model=output/xxx/xxx.pdparams ``` ### 4.4 Model Export ```bash python3 tools/export_model.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ -Global.pretrained_model=output/xxx/xxx.pdparams \ -save_inference_dir="./PP-OCRv4_server_seal_det_infer/" + Global.pretrained_model=output/xxx/xxx.pdparams \ + Global.save_inference_dir="./PP-OCRv4_server_seal_det_infer/" ``` After exporting the model, the static graph model will be stored in the `./PP-OCRv4_server_seal_det_infer/` directory. In this directory, you will see the following files: diff --git a/docs/version3.x/module_usage/seal_text_detection.md b/docs/version3.x/module_usage/seal_text_detection.md index 994d65890bc..427377aca22 100644 --- a/docs/version3.x/module_usage/seal_text_detection.md +++ b/docs/version3.x/module_usage/seal_text_detection.md @@ -474,11 +474,15 @@ PaddleOCR 对代码进行了模块化,训练 `PP-OCRv4_server_seal_det` 模型 ```bash #单卡训练 (默认训练方式) python3 tools/train.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml \ - -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams + -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams \ + Train.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Train.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/train.txt \ + Eval.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Eval.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/val.txt #多卡训练,通过--gpus参数指定卡号 python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml \ - -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams + -o Global.pretrained_model=./PP-OCRv4_server_seal_det_pretrained.pdparams \ + Train.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Train.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/train.txt \ + Eval.dataset.data_dir=./dataset/ocr_curve_det_dataset_examples Eval.dataset.label_file_list=./dataset/ocr_curve_det_dataset_examples/val.txt ``` @@ -488,17 +492,17 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs ```bash # 注意将pretrained_model的路径设置为本地路径。若使用自行训练保存的模型,请注意修改路径和文件名为{path/to/weights}/{model_name}。 - # demo 测试集评估 - python3 tools/eval.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ - Global.pretrained_model=output/xxx/xxx.pdparams +# demo 测试集评估 +python3 tools/eval.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ + Global.pretrained_model=output/xxx/xxx.pdparams ``` ### 4.4 模型导出 ```bash - python3 tools/export_model.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ - Global.pretrained_model=output/xxx/xxx.pdparams \ - save_inference_dir="./PP-OCRv4_server_seal_det_infer/" +python3 tools/export_model.py -c configs/det/PP-OCRv4/PP-OCRv4_server_seal_det.yml -o \ + Global.pretrained_model=output/xxx/xxx.pdparams \ + Global.save_inference_dir="./PP-OCRv4_server_seal_det_infer/" ``` 导出模型后,静态图模型会存放于当前目录的`./PP-OCRv4_server_seal_det_infer/`中,在该目录下,您将看到如下文件: