This commit is contained in:
SWHL committed 2022-07-11 09:50:05 +08:00
1 parent 9d1ed2ce96
commit 1ea6babaa2
7 files changed
+26 -5

No files matched your search

+1
View File
@@ -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`是用来过滤只有一行文本的图像(如下图),这类图像不会进入文本检测模块,直接进入后续过程。
+1
View File
@@ -3,6 +3,7 @@ Global:
use_angle_cls: true
print_verbose: true
min_height: 30
width_height_ratio: 8
Det:
module_name: ch_ppocr_v2_det
+8 -2
View File
@@ -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}')
+7 -1
View File
@@ -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)