From 576cbfa78ef4babe4c04fb39f9c90092d012a355 Mon Sep 17 00:00:00 2001 From: tink2123 Date: Thu, 14 May 2020 13:49:28 +0800 Subject: [PATCH] update readme --- README.md | 4 ++-- ppocr/postprocess/db_postprocess.py | 8 +++++--- tools/infer/predict_system.py | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 33995acb..8a70c8cf 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ tar -xf inference.tar export PYTHONPATH=. # 预测image_dir指定的单张图像 -python tools/infer/predict_system.py --image_dir="/Demo.jpg" --det_model_dir="./inference/det/" --rec_model_dir="./inference/rec/" +python3 tools/infer/predict_system.py --image_dir="./demo.jpg" --det_model_dir="./inference/det/" --rec_model_dir="./inference/rec/" # 预测image_dir指定的图像集合 -python tools/infer/predict_system.py --image_dir="/test_imgs/" --det_model_dir="./inference/det/" --rec_model_dir="./inference/rec/" +python3 tools/infer/predict_system.py --image_dir="./infer_imgs/" --det_model_dir="./inference/det/" --rec_model_dir="./inference/rec/" ``` 更多的文本检测、识别串联推理使用方式请参考文档教程中[基于推理引擎预测](./doc/inference.md)。 diff --git a/ppocr/postprocess/db_postprocess.py b/ppocr/postprocess/db_postprocess.py index 3f6a0514..b8e18e66 100644 --- a/ppocr/postprocess/db_postprocess.py +++ b/ppocr/postprocess/db_postprocess.py @@ -46,9 +46,11 @@ class DBPostProcess(object): bitmap = _bitmap height, width = bitmap.shape - # img, contours, _ = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) - contours, _ = cv2.findContours((bitmap * 255).astype(np.uint8), - cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) + outs = cv2.findContours((bitmap * 255).astype(np.uint8), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE) + if len(outs) == 3: + img, contours, _ = outs[0], outs[1], outs[2] + elif len(outs) == 2: + contours, _ = outs[0], outs[1] num_contours = min(len(contours), self.max_candidates) boxes = np.zeros((num_contours, 4, 2), dtype=np.int16) diff --git a/tools/infer/predict_system.py b/tools/infer/predict_system.py index 83acdbe5..3c9bc821 100755 --- a/tools/infer/predict_system.py +++ b/tools/infer/predict_system.py @@ -84,7 +84,7 @@ def sorted_boxes(dt_boxes): """ Sort text boxes in order from top to bottom, left to right args: - dt_boxes(array):detected text boxes with shape [4, 2] + dt_boxes(array):detected text boxes with shape [4, 2] return: sorted boxes(array) with shape [4, 2] """ @@ -108,6 +108,7 @@ if __name__ == "__main__": is_visualize = True for image_file in image_file_list: img = cv2.imread(image_file) + print(img.shape) if img is None: logger.info("error in loading image:{}".format(image_file)) continue -- GitLab