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 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(result)
  18. @unittest.skip('will be enabled after damoyolo officially released')
  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(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, model='damo/cv_tinynas_detection')
  34. result = tinynas_object_detection(test_image)
  35. tinynas_object_detection.show_result(test_image, result,
  36. 'demo_ret.jpg')
  37. if __name__ == '__main__':
  38. unittest.main()