diff --git a/README.md b/README.md index 33995acb4cbb35252b8fd6c6a9f10a0bb07f3757..8a70c8cf170e1cc5e5af75e31726d29a9e867d23 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 3f6a051415545204e15192adf3bee96095474f73..b8e18e66c8ac491b67c9a06d26dcf42ffa175011 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 83acdbe5edbbdc1b5cf92565ebbe787304e8d103..de2c1e6387c183d85e13601954337dbe84922cc2 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] """