You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_ocr_detection.py 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import os.path as osp
  3. import shutil
  4. import sys
  5. import tempfile
  6. import unittest
  7. from typing import Any, Dict, List, Tuple, Union
  8. import cv2
  9. import numpy as np
  10. import PIL
  11. from modelscope.pipelines import pipeline
  12. from modelscope.pipelines.base import Pipeline
  13. from modelscope.utils.constant import Tasks
  14. from modelscope.utils.test_utils import test_level
  15. class OCRDetectionTest(unittest.TestCase):
  16. def setUp(self) -> None:
  17. self.model_id = 'damo/cv_resnet18_ocr-detection-line-level_damo'
  18. self.test_image = 'data/test/images/ocr_detection.jpg'
  19. def pipeline_inference(self, pipeline: Pipeline, input_location: str):
  20. result = pipeline(input_location)
  21. print('ocr detection results: ')
  22. print(result)
  23. @unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
  24. def test_run_modelhub_default_model(self):
  25. ocr_detection = pipeline(Tasks.ocr_detection)
  26. self.pipeline_inference(ocr_detection, self.test_image)
  27. if __name__ == '__main__':
  28. unittest.main()