support traffic-sign detection

支持cv垂类交通标识检测模型

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11535569
This commit is contained in:
lanjinpeng.ljp
2023-02-09 06:35:00 +00:00
committed by wenmeng.zwm
parent a8f717dd13
commit a8a0cef71e
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b6ab556a1d69010cfe6dd136ff3fbd17ed122c6d0c3509667ef40a656bc18464
size 87334

View File

@@ -0,0 +1,48 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import unittest
from PIL import Image
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.demo_utils import DemoCompatibilityCheck
from modelscope.utils.test_utils import test_level
class TrafficSignDetectionTest(unittest.TestCase, DemoCompatibilityCheck):
def setUp(self) -> None:
self.task = Tasks.domain_specific_object_detection
self.model_id = 'damo/cv_tinynas_object-detection_damoyolo_traffic_sign'
@unittest.skip('demo compatibility test is only enabled on a needed-basis')
def test_demo_compatibility(self):
self.compatibility_check()
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_traffic_sign_detection_damoyolo(self):
tinynas_object_detection = pipeline(
Tasks.domain_specific_object_detection,
model='damo/cv_tinynas_object-detection_damoyolo_traffic_sign')
result = tinynas_object_detection(
'data/test/images/image_traffic_sign.jpg')
assert result and (OutputKeys.SCORES in result) and (
OutputKeys.LABELS in result) and (OutputKeys.BOXES in result)
print('results: ', result)
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
def test_traffic_sign_detection_damoyolo_with_image(self):
tinynas_object_detection = pipeline(
Tasks.domain_specific_object_detection,
model='damo/cv_tinynas_object-detection_damoyolo_traffic_sign')
img = Image.open('data/test/images/image_traffic_sign.jpg')
result = tinynas_object_detection(img)
assert result and (OutputKeys.SCORES in result) and (
OutputKeys.LABELS in result) and (OutputKeys.BOXES in result)
print('results: ', result)
if __name__ == '__main__':
unittest.main()