mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 04:01:10 +01:00
support traffic-sign detection
支持cv垂类交通标识检测模型 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11535569
This commit is contained in:
committed by
wenmeng.zwm
parent
a8f717dd13
commit
a8a0cef71e
3
data/test/images/image_traffic_sign.jpg
Normal file
3
data/test/images/image_traffic_sign.jpg
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b6ab556a1d69010cfe6dd136ff3fbd17ed122c6d0c3509667ef40a656bc18464
|
||||
size 87334
|
||||
48
tests/pipelines/test_traffic_sign_detection.py
Normal file
48
tests/pipelines/test_traffic_sign_detection.py
Normal 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()
|
||||
Reference in New Issue
Block a user