📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.
Fix issue #34
SWHL1ea6babaa23c
diff --git a/ocrweb/config.yaml b/ocrweb/config.yamlindex a55a535..9eb61d1 100644--- a/ocrweb/config.yaml+++ b/ocrweb/config.yaml@@ -3,6 +3,7 @@ Global:use_angle_cls: trueprint_verbose: truemin_height: 30+ width_height_ratio: 8Det:module_name: ch_ppocr_v2_detdiff --git a/ocrweb/main.py b/ocrweb/main.pyindex 943d2bc..f792ab4 100644--- a/ocrweb/main.py+++ b/ocrweb/main.py@@ -35,4 +35,4 @@ def ocr():if __name__ == '__main__':- app.run(host='0.0.0.0', port=9003, debug=False, processes=True)+ app.run(host='0.0.0.0', port=9003, debug=True, processes=True)diff --git a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.pyindex 572041f..89219ab 100644--- a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py+++ b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py@@ -23,6 +23,7 @@ class TextSystem(object):self.print_verbose = global_config['print_verbose']self.text_score = global_config['text_score']self.min_height = global_config['min_height']+ self.width_height_ratio = global_config['width_height_ratio']TextDetector = self.init_module(config['Det']['module_name'],config['Det']['class_name'])@@ -40,7 +41,12 @@ class TextSystem(object):def __call__(self, img: np.ndarray):h, w = img.shape[:2]- if h < self.min_height:+ if self.width_height_ratio == -1:+ use_limit_ratio = False+ else:+ use_limit_ratio = w / h > self.width_height_ratio++ if h <= self.min_height or use_limit_ratio:start_time = time.time()dt_boxes, img_crop_list = self.get_boxes_img_without_det(img, h, w)crop_elapse = time.time() - start_timediff --git a/python/README.md b/python/README.mdindex 0005c08..66f0b16 100755--- a/python/README.md+++ b/python/README.md@@ -148,6 +148,7 @@| `use_angle_cls` | `bool` | `true` | 是否使用文本行的方向分类 || `print_verbose` | `bool` | `true` | 是否打印各个部分耗时信息 || `min_height` | `int` | 30 | 图像最小高度(单位是像素)<br/>低于这个值,会跳过文本检测阶段,直接进行后续识别 |+ |`width_height_ratio`| `int`| 8| 如果输入图像的宽高比大于`width_height_ratio`,则会跳过文本检测,直接进行后续识别<br/>`width_height_ratio=-1`:不用这个参数 |- `min_height`是用来过滤只有一行文本的图像(如下图),这类图像不会进入文本检测模块,直接进入后续过程。diff --git a/python/config.yaml b/python/config.yamlindex a55a535..9eb61d1 100644--- a/python/config.yaml+++ b/python/config.yaml@@ -3,6 +3,7 @@ Global:use_angle_cls: trueprint_verbose: truemin_height: 30+ width_height_ratio: 8Det:module_name: ch_ppocr_v2_detdiff --git a/python/rapidocr_onnxruntime/rapid_ocr_api.py b/python/rapidocr_onnxruntime/rapid_ocr_api.pyindex 1bb7051..9c2f8a9 100644--- a/python/rapidocr_onnxruntime/rapid_ocr_api.py+++ b/python/rapidocr_onnxruntime/rapid_ocr_api.py@@ -26,6 +26,7 @@ class TextSystem(object):self.print_verbose = global_config['print_verbose']self.text_score = global_config['text_score']self.min_height = global_config['min_height']+ self.width_height_ratio = global_config['width_height_ratio']TextDetector = self.init_module(config['Det']['module_name'],config['Det']['class_name'])@@ -43,7 +44,12 @@ class TextSystem(object):def __call__(self, img: np.ndarray):h, w = img.shape[:2]- if h <= self.min_height:+ if self.width_height_ratio == -1:+ use_limit_ratio = False+ else:+ use_limit_ratio = w / h > self.width_height_ratio++ if h <= self.min_height or use_limit_ratio:dt_boxes, img_crop_list = self.get_boxes_img_without_det(img, h, w)else:dt_boxes, elapse = self.text_detector(img)@@ -56,7 +62,7 @@ class TextSystem(object):img_crop_list = self.get_crop_img_list(img, dt_boxes)if self.use_angle_cls:- img_crop_list, angle_list, elapse = self.text_cls(img_crop_list)+ img_crop_list, _, elapse = self.text_cls(img_crop_list)if self.print_verbose:print(f'cls num: {len(img_crop_list)}, elapse: {elapse}')diff --git a/python/rapidocr_openvino/rapid_ocr_api.py b/python/rapidocr_openvino/rapid_ocr_api.pyindex 402562d..fba75fe 100644--- a/python/rapidocr_openvino/rapid_ocr_api.py+++ b/python/rapidocr_openvino/rapid_ocr_api.py@@ -24,6 +24,7 @@ class TextSystem(object):self.print_verbose = global_config['print_verbose']self.text_score = global_config['text_score']self.min_height = global_config['min_height']+ self.width_height_ratio = global_config['width_height_ratio']TextDetector = self.init_module(config['Det']['module_name'],config['Det']['class_name'])@@ -41,7 +42,12 @@ class TextSystem(object):def __call__(self, img: np.ndarray):h, w = img.shape[:2]- if h < self.min_height:+ if self.width_height_ratio == -1:+ use_limit_ratio = False+ else:+ use_limit_ratio = w / h > self.width_height_ratio++ if h <= self.min_height or use_limit_ratio:dt_boxes, img_crop_list = self.get_boxes_img_without_det(img, h, w)else:dt_boxes, elapse = self.text_detector(img)