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.2 kB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. from modelscope.pipelines import pipeline
  4. from modelscope.pipelines.base import Pipeline
  5. from modelscope.utils.constant import Tasks
  6. from modelscope.utils.test_utils import test_level
  7. class OCRDetectionTest(unittest.TestCase):
  8. def setUp(self) -> None:
  9. self.model_id = 'damo/cv_resnet18_ocr-detection-line-level_damo'
  10. self.test_image = 'data/test/images/ocr_detection.jpg'
  11. def pipeline_inference(self, pipeline: Pipeline, input_location: str):
  12. result = pipeline(input_location)
  13. print('ocr detection results: ')
  14. print(result)
  15. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  16. def test_run_with_model_from_modelhub(self):
  17. ocr_detection = pipeline(Tasks.ocr_detection, model=self.model_id)
  18. self.pipeline_inference(ocr_detection, self.test_image)
  19. @unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
  20. def test_run_modelhub_default_model(self):
  21. ocr_detection = pipeline(Tasks.ocr_detection)
  22. self.pipeline_inference(ocr_detection, self.test_image)
  23. if __name__ == '__main__':
  24. unittest.main()