mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-17 00:37:43 +01:00
商品显著性检测模型,依赖opencv,mmcv-full
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9909897
25 lines
876 B
Python
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()
|