You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_tinynas_detection.py 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. from modelscope.pipelines import pipeline
  4. from modelscope.utils.constant import Tasks
  5. from modelscope.utils.demo_utils import DemoCompatibilityCheck
  6. from modelscope.utils.test_utils import test_level
  7. class TinynasObjectDetectionTest(unittest.TestCase, DemoCompatibilityCheck):
  8. def setUp(self) -> None:
  9. self.task = Tasks.image_object_detection
  10. self.model_id = 'damo/cv_tinynas_object-detection_damoyolo'
  11. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  12. def test_run_airdet(self):
  13. tinynas_object_detection = pipeline(
  14. Tasks.image_object_detection, model='damo/cv_tinynas_detection')
  15. result = tinynas_object_detection(
  16. 'data/test/images/image_detection.jpg')
  17. print('airdet', result)
  18. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  19. def test_run_damoyolo(self):
  20. tinynas_object_detection = pipeline(
  21. Tasks.image_object_detection,
  22. model='damo/cv_tinynas_object-detection_damoyolo')
  23. result = tinynas_object_detection(
  24. 'data/test/images/image_detection.jpg')
  25. print('damoyolo', result)
  26. @unittest.skip('demo compatibility test is only enabled on a needed-basis')
  27. def test_demo_compatibility(self):
  28. self.compatibility_check()
  29. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  30. def test_image_object_detection_auto_pipeline(self):
  31. test_image = 'data/test/images/image_detection.jpg'
  32. tinynas_object_detection = pipeline(
  33. Tasks.image_object_detection,
  34. model='damo/cv_tinynas_object-detection_damoyolo')
  35. result = tinynas_object_detection(test_image)
  36. tinynas_object_detection.show_result(test_image, result,
  37. 'demo_ret.jpg')
  38. if __name__ == '__main__':
  39. unittest.main()