mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-16 16:27:45 +01:00
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9662182 * clean up test level
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
import unittest
|
|
|
|
from modelscope.pipelines import pipeline
|
|
from modelscope.pipelines.base import Pipeline
|
|
from modelscope.utils.constant import Tasks
|
|
from modelscope.utils.test_utils import test_level
|
|
|
|
|
|
class OCRDetectionTest(unittest.TestCase):
|
|
|
|
def setUp(self) -> None:
|
|
self.model_id = 'damo/cv_resnet18_ocr-detection-line-level_damo'
|
|
self.test_image = 'data/test/images/ocr_detection.jpg'
|
|
|
|
def pipeline_inference(self, pipeline: Pipeline, input_location: str):
|
|
result = pipeline(input_location)
|
|
print('ocr detection results: ')
|
|
print(result)
|
|
|
|
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
|
def test_run_with_model_from_modelhub(self):
|
|
ocr_detection = pipeline(Tasks.ocr_detection, model=self.model_id)
|
|
self.pipeline_inference(ocr_detection, self.test_image)
|
|
|
|
@unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
|
|
def test_run_modelhub_default_model(self):
|
|
ocr_detection = pipeline(Tasks.ocr_detection)
|
|
self.pipeline_inference(ocr_detection, self.test_image)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|