Files
modelscope/tests/pipelines/test_shop_segmentation.py
xingguang.zxg 0451627626 [to #42322933]商品显著性分割v1.0
商品显著性检测模型,依赖opencv,mmcv-full
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9909897
2022-09-03 13:21:31 +08:00

25 lines
876 B
Python

# Copyright (c) Alibaba, Inc. and its affiliates.
import unittest
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 ShopSegmentationTest(unittest.TestCase):
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_shop_segmentation(self):
input_location = 'data/test/images/shop_segmentation.jpg'
model_id = 'damo/cv_vitb16_segmentation_shop-seg'
shop_seg = pipeline(Tasks.shop_segmentation, model=model_id)
result = shop_seg(input_location)
import cv2
# result[OutputKeys.MASKS] is segment map result,other keys are not used
cv2.imwrite(input_location + '_shopseg.jpg', result[OutputKeys.MASKS])
if __name__ == '__main__':
unittest.main()