mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 12:10:09 +01:00
[to #42322933] add domain specific object detection models
添加垂类目标检测模型。
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11265502
This commit is contained in:
3
data/test/images/image_safetyhat.jpg
Normal file
3
data/test/images/image_safetyhat.jpg
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3dca477e8a0e25bccb4966ddaebad75d7c770deb1c5e55b9b5e9f39078ea84c2
|
||||
size 168454
|
||||
3
data/test/images/image_smoke.jpg
Normal file
3
data/test/images/image_smoke.jpg
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0dbbcaa0bb6b2c64b1c360f03913b7ab5386a846cc81c34825c115c41c4d672a
|
||||
size 23345
|
||||
@@ -7,7 +7,8 @@ from .detector import SingleStageDetector
|
||||
|
||||
|
||||
@MODELS.register_module(
|
||||
Tasks.human_detection, module_name=Models.tinynas_damoyolo)
|
||||
Tasks.domain_specific_object_detection,
|
||||
module_name=Models.tinynas_damoyolo)
|
||||
@MODELS.register_module(
|
||||
Tasks.image_object_detection, module_name=Models.tinynas_damoyolo)
|
||||
class DamoYolo(SingleStageDetector):
|
||||
|
||||
@@ -219,6 +219,8 @@ TASK_OUTPUTS = {
|
||||
# }
|
||||
Tasks.image_object_detection:
|
||||
[OutputKeys.SCORES, OutputKeys.LABELS, OutputKeys.BOXES],
|
||||
Tasks.domain_specific_object_detection:
|
||||
[OutputKeys.SCORES, OutputKeys.LABELS, OutputKeys.BOXES],
|
||||
|
||||
# video object detection result for single sample
|
||||
# {
|
||||
@@ -370,8 +372,9 @@ TASK_OUTPUTS = {
|
||||
# ],
|
||||
# "timestamps": ["hh:mm:ss", "hh:mm:ss", "hh:mm:ss"]
|
||||
# }
|
||||
Tasks.video_single_object_tracking:
|
||||
[OutputKeys.BOXES, OutputKeys.TIMESTAMPS],
|
||||
Tasks.video_single_object_tracking: [
|
||||
OutputKeys.BOXES, OutputKeys.TIMESTAMPS
|
||||
],
|
||||
|
||||
# live category recognition result for single video
|
||||
# {
|
||||
|
||||
@@ -78,6 +78,8 @@ TASK_INPUTS = {
|
||||
InputType.IMAGE,
|
||||
Tasks.image_object_detection:
|
||||
InputType.IMAGE,
|
||||
Tasks.domain_specific_object_detection:
|
||||
InputType.IMAGE,
|
||||
Tasks.image_segmentation:
|
||||
InputType.IMAGE,
|
||||
Tasks.portrait_matting:
|
||||
|
||||
@@ -20,7 +20,8 @@ logger = get_logger()
|
||||
|
||||
|
||||
@PIPELINES.register_module(
|
||||
Tasks.human_detection, module_name=Pipelines.tinynas_detection)
|
||||
Tasks.domain_specific_object_detection,
|
||||
module_name=Pipelines.tinynas_detection)
|
||||
@PIPELINES.register_module(
|
||||
Tasks.image_object_detection, module_name=Pipelines.tinynas_detection)
|
||||
class TinynasDetectionPipeline(Pipeline):
|
||||
|
||||
@@ -108,6 +108,9 @@ class CVTasks(object):
|
||||
# pointcloud task
|
||||
pointcloud_sceneflow_estimation = 'pointcloud-sceneflow-estimation'
|
||||
|
||||
# domain specific object detection
|
||||
domain_specific_object_detection = 'domain-specific-object-detection'
|
||||
|
||||
|
||||
class NLPTasks(object):
|
||||
# nlp tasks
|
||||
|
||||
@@ -69,7 +69,7 @@ class TinynasObjectDetectionTest(unittest.TestCase, DemoCompatibilityCheck):
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_human_detection_damoyolo(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.human_detection,
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_human-detection_damoyolo')
|
||||
result = tinynas_object_detection(
|
||||
'data/test/images/image_detection.jpg')
|
||||
@@ -80,7 +80,7 @@ class TinynasObjectDetectionTest(unittest.TestCase, DemoCompatibilityCheck):
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_human_detection_damoyolo_with_image(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.human_detection,
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_human-detection_damoyolo')
|
||||
img = Image.open('data/test/images/image_detection.jpg')
|
||||
result = tinynas_object_detection(img)
|
||||
@@ -88,6 +88,71 @@ class TinynasObjectDetectionTest(unittest.TestCase, DemoCompatibilityCheck):
|
||||
OutputKeys.LABELS in result) and (OutputKeys.BOXES in result)
|
||||
print('results: ', result)
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_facemask_detection_damoyolo(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_facemask')
|
||||
result = tinynas_object_detection(
|
||||
'data/test/images/image_detection.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_facemask_detection_damoyolo_with_image(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_facemask')
|
||||
img = Image.open('data/test/images/image_detection.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)
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_safetyhat_detection_damoyolo(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_safety-helmet')
|
||||
result = tinynas_object_detection(
|
||||
'data/test/images/image_safetyhat.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_safetyhat_detection_damoyolo_with_image(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_safety-helmet')
|
||||
img = Image.open('data/test/images/image_safetyhat.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)
|
||||
|
||||
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
||||
def test_cigarette_detection_damoyolo(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_cigarette')
|
||||
result = tinynas_object_detection('data/test/images/image_smoke.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_cigarette_detection_damoyolo_with_image(self):
|
||||
tinynas_object_detection = pipeline(
|
||||
Tasks.domain_specific_object_detection,
|
||||
model='damo/cv_tinynas_object-detection_damoyolo_cigarette')
|
||||
img = Image.open('data/test/images/image_smoke.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