diff --git a/doc/doc_ch/detection.md b/doc/doc_ch/detection.md index a8dee65a220e3c66d8502181dd2a542cb01a29b5..671fda998d523405e22692ade5c7dced6e1f390c 100644 --- a/doc/doc_ch/detection.md +++ b/doc/doc_ch/detection.md @@ -108,9 +108,9 @@ PaddleOCR计算三个OCR检测相关的指标,分别是:Precision、Recall 运行如下代码,根据配置文件`det_db_mv3.yml`中`save_res_path`指定的测试集检测结果文件,计算评估指标。 评估时设置后处理参数`box_thresh=0.5`,`unclip_ratio=1.5`,使用不同数据集、不同模型训练,可调整这两个参数进行优化 -训练中模型参数默认保存在`Global.save_model_dir`目录下。在评估指标时,需要设置`Global.checkpoints`指向保存的参数文件。 +训练中模型参数默认保存在`Global.save_model_dir`目录下。在评估指标时,需要设置`Global.pretrained_model`指向保存的参数文件。 ```shell -python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{path/to/weights}/best_accuracy" PostProcess.box_thresh=0.5 PostProcess.unclip_ratio=1.5 +python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model="{path/to/weights}/best_accuracy" PostProcess.box_thresh=0.5 PostProcess.unclip_ratio=1.5 ``` diff --git a/doc/doc_ch/recognition.md b/doc/doc_ch/recognition.md index 028a248fe6ba72d435ed2f0a1b21629f35851be9..faa015b754f4c47e6789049df60264f0dd468784 100644 --- a/doc/doc_ch/recognition.md +++ b/doc/doc_ch/recognition.md @@ -420,8 +420,8 @@ Eval: 评估数据集可以通过 `configs/rec/rec_icdar15_train.yml` 修改Eval中的 `label_file_path` 设置。 ``` -# GPU 评估, Global.checkpoints 为待测权重 -python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec_icdar15_train.yml -o Global.checkpoints={path/to/weights}/best_accuracy +# GPU 评估, Global.pretrained_model 为待测权重 +python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec_icdar15_train.yml -o Global.pretrained_model={path/to/weights}/best_accuracy ``` @@ -432,7 +432,7 @@ python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec 使用 PaddleOCR 训练好的模型,可以通过以下脚本进行快速预测。 -默认预测图片存储在 `infer_img` 里,通过 `-o Global.checkpoints` 指定权重: +默认预测图片存储在 `infer_img` 里,通过 `-o Global.pretrained_model` 指定权重: ``` # 预测英文结果 diff --git a/doc/doc_en/detection_en.md b/doc/doc_en/detection_en.md index 3ee9092cc6a6f50b19f20df646c9cb1949d5d80f..897f5b3b09077da59cf213709c40c1850d734e39 100644 --- a/doc/doc_en/detection_en.md +++ b/doc/doc_en/detection_en.md @@ -101,9 +101,9 @@ Run the following code to calculate the evaluation indicators. The result will b When evaluating, set post-processing parameters `box_thresh=0.6`, `unclip_ratio=1.5`. If you use different datasets, different models for training, these two parameters should be adjusted for better result. -The model parameters during training are saved in the `Global.save_model_dir` directory by default. When evaluating indicators, you need to set `Global.checkpoints` to point to the saved parameter file. +The model parameters during training are saved in the `Global.save_model_dir` directory by default. When evaluating indicators, you need to set `Global.pretrained_model` to point to the saved parameter file. ```shell -python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{path/to/weights}/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 +python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model="{path/to/weights}/best_accuracy" PostProcess.box_thresh=0.6 PostProcess.unclip_ratio=1.5 ``` diff --git a/doc/doc_en/recognition_en.md b/doc/doc_en/recognition_en.md index 73157f864c456b92a580d22d28b2003bff68e578..67eece7e85ce29df2d7601ae72f06c9a71061f0b 100644 --- a/doc/doc_en/recognition_en.md +++ b/doc/doc_en/recognition_en.md @@ -425,8 +425,8 @@ Eval: The evaluation dataset can be set by modifying the `Eval.dataset.label_file_list` field in the `configs/rec/rec_icdar15_train.yml` file. ``` -# GPU evaluation, Global.checkpoints is the weight to be tested -python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec_icdar15_train.yml -o Global.checkpoints={path/to/weights}/best_accuracy +# GPU evaluation, Global.pretrained_model is the weight to be tested +python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec_icdar15_train.yml -o Global.pretrained_model={path/to/weights}/best_accuracy ``` @@ -437,7 +437,7 @@ python3 -m paddle.distributed.launch --gpus '0' tools/eval.py -c configs/rec/rec Using the model trained by paddleocr, you can quickly get prediction through the following script. -The default prediction picture is stored in `infer_img`, and the weight is specified via `-o Global.checkpoints`: +The default prediction picture is stored in `infer_img`, and the weight is specified via `-o Global.pretrained_model`: ``` # Predict English results diff --git a/doc/joinus.PNG b/doc/joinus.PNG index 1eeef6be39327f3d9f9e862689d10d8e02579f58..477760f674438f487ac906bb4692c2df066409a8 100644 Binary files a/doc/joinus.PNG and b/doc/joinus.PNG differ diff --git a/ppocr/postprocess/rec_postprocess.py b/ppocr/postprocess/rec_postprocess.py index b0517982f00ff7e283b613309b3676d793e8b7ad..c769b7b4a3076645b0fefe27d1271dedd4ad2d19 100644 --- a/ppocr/postprocess/rec_postprocess.py +++ b/ppocr/postprocess/rec_postprocess.py @@ -216,6 +216,7 @@ class SRNLabelDecode(BaseRecLabelDecode): character_type='en', use_space_char=False, **kwargs): + self.max_text_length = kwargs['max_text_length'] super(SRNLabelDecode, self).__init__(character_dict_path, character_type, use_space_char) @@ -229,9 +230,9 @@ class SRNLabelDecode(BaseRecLabelDecode): preds_idx = np.argmax(pred, axis=1) preds_prob = np.max(pred, axis=1) - preds_idx = np.reshape(preds_idx, [-1, 25]) + preds_idx = np.reshape(preds_idx, [-1, self.max_text_length]) - preds_prob = np.reshape(preds_prob, [-1, 25]) + preds_prob = np.reshape(preds_prob, [-1, self.max_text_length]) text = self.decode(preds_idx, preds_prob) diff --git a/tools/infer/predict_system.py b/tools/infer/predict_system.py index de7ee9d342063161f2e329c99d2428051c0ecf8c..ea622fac5e5870437907ee8c5b8068d77ecd3c0c 100755 --- a/tools/infer/predict_system.py +++ b/tools/infer/predict_system.py @@ -176,6 +176,8 @@ def main(args): draw_img_save = "./inference_results/" if not os.path.exists(draw_img_save): os.makedirs(draw_img_save) + if flag: + image_file = image_file[:-3] + "png" cv2.imwrite( os.path.join(draw_img_save, os.path.basename(image_file)), draw_img[:, :, ::-1])