Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Add parameter whether using the text det module.

SWHLd16834632196
diff --git a/ocrweb/README.md b/ocrweb/README.md
index d57e88c..45040ff 100755
--- a/ocrweb/README.md
+++ b/ocrweb/README.md
@@ -2,6 +2,7 @@
- [RapidOCR Web Demo](#rapidocr-web-demo)
- [简要说明](#简要说明)
+ - [config.yaml全局参数说明](#configyaml全局参数说明)
- [以Web方式运行](#以web方式运行)
- [以API方式运行](#以api方式运行)
@@ -18,6 +19,16 @@
<img src="../assets/ocrweb_time.jpg" width="80%" height="80%">
</div>
+### config.yaml全局参数说明
+```text
+Global:
+ text_score: 0.5
+ use_angle_cls: true # 是否使用文本框分类模型,默认为True
+ use_text_det: true # 是否使用文本检测模型,默认为True
+ print_verbose: true # 使用打印各个阶段的运行时长到终端,默认为True
+ min_height: 30 # 图像高度小于30将不经过文本检测模型
+ width_height_ratio: 8 # 图像宽高比大于该值,则不经过文本检测模型
+```
### 以Web方式运行
diff --git a/ocrweb/config.yaml b/ocrweb/config.yaml
index 5b84273..81de531 100644
--- a/ocrweb/config.yaml
+++ b/ocrweb/config.yaml
@@ -1,6 +1,7 @@
Global:
text_score: 0.5
use_angle_cls: true
+ use_text_det: true
print_verbose: true
min_height: 30
width_height_ratio: 8
diff --git a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
index 89219ab..d5f4846 100644
--- a/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
+++ b/ocrweb/rapidocr_onnxruntime/rapid_ocr_api.py
@@ -25,9 +25,11 @@ class TextSystem(object):
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'])
- self.text_detector = TextDetector(config['Det'])
+ self.use_text_det = config['Global']['use_text_det']
+ if self.use_text_det:
+ TextDetector = self.init_module(config['Det']['module_name'],
+ config['Det']['class_name'])
+ self.text_detector = TextDetector(config['Det'])
TextRecognizer = self.init_module(config['Rec']['module_name'],
config['Rec']['class_name'])
@@ -46,7 +48,9 @@ class TextSystem(object):
else:
use_limit_ratio = w / h > self.width_height_ratio
- if h <= self.min_height or use_limit_ratio:
+ if not self.use_text_det \
+ or 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_time