From 8cbdf0372246ce7466a3742bbab4a0bff2fa9f0f Mon Sep 17 00:00:00 2001 From: "lee.lcy" Date: Wed, 8 Feb 2023 11:44:56 +0000 Subject: [PATCH] [to #42322933] add head&phone detection models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加人头检测模型和手机检测模型 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11519119 * add phone detection models * add head detection model --- data/test/images/image_phone.jpg | 3 ++ tests/pipelines/test_tinynas_detection.py | 43 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 data/test/images/image_phone.jpg diff --git a/data/test/images/image_phone.jpg b/data/test/images/image_phone.jpg new file mode 100644 index 00000000..7c116b69 --- /dev/null +++ b/data/test/images/image_phone.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10b494cbc1a29b228745bcb26897e2524569b467b88cc9839be38504d268ca30 +size 55485 diff --git a/tests/pipelines/test_tinynas_detection.py b/tests/pipelines/test_tinynas_detection.py index a73e7b0c..4c3735dc 100644 --- a/tests/pipelines/test_tinynas_detection.py +++ b/tests/pipelines/test_tinynas_detection.py @@ -153,6 +153,49 @@ 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_phone_detection_damoyolo(self): + tinynas_object_detection = pipeline( + Tasks.domain_specific_object_detection, + model='damo/cv_tinynas_object-detection_damoyolo_phone') + result = tinynas_object_detection('data/test/images/image_phone.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_phone_detection_damoyolo_with_image(self): + tinynas_object_detection = pipeline( + Tasks.domain_specific_object_detection, + model='damo/cv_tinynas_object-detection_damoyolo_phone') + img = Image.open('data/test/images/image_phone.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_head_detection_damoyolo(self): + tinynas_object_detection = pipeline( + Tasks.domain_specific_object_detection, + model='damo/cv_tinynas_head-detection_damoyolo') + 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_head_detection_damoyolo_with_image(self): + tinynas_object_detection = pipeline( + Tasks.domain_specific_object_detection, + model='damo/cv_tinynas_head-detection_damoyolo') + 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) + if __name__ == '__main__': unittest.main()