mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-24 03:59:23 +01:00
add 1.6
This commit is contained in:
34
tests/pipelines/test_fast_instance_segmentation.py
Normal file
34
tests/pipelines/test_fast_instance_segmentation.py
Normal 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()
|
||||
Reference in New Issue
Block a user