This commit is contained in:
xingjun.wang
2023-05-22 10:53:18 +08:00
parent 52aea36c12
commit 48c0d2a9af
468 changed files with 12942 additions and 7176 deletions

View File

@@ -0,0 +1,34 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import unittest
from modelscope.models import Model
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.test_utils import test_level
class FastInstanceSegmentationTest(unittest.TestCase):
def setUp(self) -> None:
self.task = Tasks.image_segmentation
self.model_id = 'damo/cv_resnet50_fast-instance-segmentation_coco'
image = 'data/test/images/image_instance_segmentation.jpg'
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_run_with_model_name(self):
pipeline_parsing = pipeline(
task=Tasks.image_segmentation, model=self.model_id)
print(pipeline_parsing(input=self.image)[OutputKeys.LABELS])
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
def test_run_with_model_from_modelhub(self):
model = Model.from_pretrained(self.model_id)
pipeline_parsing = pipeline(
task=Tasks.image_segmentation, model=model, preprocessor=None)
print(pipeline_parsing(input=self.image)[OutputKeys.LABELS])
if __name__ == '__main__':
unittest.main()