📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Add parameters comment of python version
SWHL6aa79aa390c9
diff --git a/python/README.md b/python/README.mdindex 8a68678..15962de 100755--- a/python/README.md+++ b/python/README.md@@ -30,6 +30,14 @@ dt_boxes, rec_res = text_sys(image_path)visualize(image_path, dt_boxes, rec_res)```+#### 相关调节参数如下+|参数名称|作用|建议取值范围|默认值|代码位置|+|:---:|:---:|:---:|:---:|:---:|+|box_thresh|文本检测所得框是否保留的阈值,值越大,召回率越低|[0, 1]|0.5||+|unclip_ratio|控制文本检测框的大小,值越大,检测框整体越大|[1.6, 2.0]|1.6||+|text_score|文本识别结果置信度,值越大,把握越大|[0, 1]|0.5||++### onnxruntime-gpu版推理配置1. 安装GPU版的onnxruntime: `pip install onnxruntime-gpu`2. 推理代码中,加载onnx模型部分,用以下对应语言代码替换即可,详细参见:[官方教程](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html)diff --git a/python/rapidOCR.py b/python/rapidOCR.pyindex 8c09c04..f579cca 100644--- a/python/rapidOCR.py+++ b/python/rapidOCR.py@@ -11,8 +11,6 @@ import cv2import numpy as npfrom PIL import Image, ImageDraw, ImageFont-drop_score = 0.5-def get_image_file_list(img_file):if img_file is None or not Path(img_file).exists():@@ -75,7 +73,7 @@ def check_and_read_gif(img_path):def draw_ocr_box_txt(image, boxes, txts,- scores=None, drop_score=0.5,+ scores=None, text_score=0.5,font_path="./models/msyh.ttc"):h, w = image.height, image.widthimg_left = image.copy()@@ -85,7 +83,7 @@ def draw_ocr_box_txt(image, boxes, txts,draw_left = ImageDraw.Draw(img_left)draw_right = ImageDraw.Draw(img_right)for idx, (box, txt) in enumerate(zip(boxes, txts)):- if scores is not None and scores[idx] < drop_score:+ if scores is not None and scores[idx] < text_score:continuecolor = (random.randint(0, 255),@@ -135,7 +133,7 @@ def visualize(image_path, boxes, rec_res):draw_img = draw_ocr_box_txt(image, boxes,txts, scores,- drop_score=0.5)+ text_score=0.5)draw_img_save = Path("./inference_results/")if not draw_img_save.exists():@@ -249,7 +247,7 @@ class TextSystem(object):filter_boxes, filter_rec_res = [], []for box, rec_reuslt in zip(dt_boxes, rec_res):text, score = rec_reuslt- if score >= drop_score:+ if score >= text_score:filter_boxes.append(box)filter_rec_res.append(rec_reuslt)return filter_boxes, filter_rec_res@@ -267,7 +265,9 @@ if __name__ == '__main__':parser.add_argument('--image_path', type=str,default='test_images/det_images/')+ parser.add_argument('--text_score', type=float, default=0.5)args = parser.parse_args()+ text_score = args.text_scorefrom ch_ppocr_mobile_v2_cls import TextClassifierdiff --git a/python/rapidOCR.sh b/python/rapidOCR.shindex ac0260b..a8afaf0 100644--- a/python/rapidOCR.sh+++ b/python/rapidOCR.sh@@ -1,7 +1,10 @@#! /bin/bash-set -e errexit++# The img_path can be file path or folder path.+img_path="test_images/det_images/1.jpg"python rapidOCR.py --det_model_path models/ch_ppocr_mobile_v2.0_det_infer.onnx \--cls_model_path models/ch_ppocr_mobile_v2.0_cls_infer.onnx \--rec_model_path models/ch_ppocr_mobile_v2.0_rec_infer.onnx \- --image_path test_images/det_images/1.jpg+ --image_path ${img_path} \+ --text_score 0.5