From 00487aa6e1ca1b7ac50b5ca90b3290f2a6068d77 Mon Sep 17 00:00:00 2001 From: "xixing.tj" Date: Sat, 3 Sep 2022 11:38:07 +0800 Subject: [PATCH] [to #42322933]add error msg when no text detected for ocr_detection task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ocr_detection加上当图片中没有文字时报错的error msg Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10001490 --- modelscope/pipelines/cv/ocr_detection_pipeline.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modelscope/pipelines/cv/ocr_detection_pipeline.py b/modelscope/pipelines/cv/ocr_detection_pipeline.py index 62248714..b73f65a4 100644 --- a/modelscope/pipelines/cv/ocr_detection_pipeline.py +++ b/modelscope/pipelines/cv/ocr_detection_pipeline.py @@ -149,6 +149,8 @@ class OCRDetectionPipeline(Pipeline): def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, Any]: rboxes = inputs['combined_rboxes'][0] count = inputs['combined_counts'][0] + if count == 0 or count < rboxes.shape[0]: + raise Exception('modelscope error: No text detected') rboxes = rboxes[:count, :] # convert rboxes to polygons and find its coordinates on the original image