Browse Source

[to #42322933]add error msg when no text detected for ocr_detection task

ocr_detection加上当图片中没有文字时报错的error msg
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10001490
master
xixing.tj yingda.chen 3 years ago
parent
commit
00487aa6e1
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      modelscope/pipelines/cv/ocr_detection_pipeline.py

+ 2
- 0
modelscope/pipelines/cv/ocr_detection_pipeline.py View File

@@ -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


Loading…
Cancel
Save