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.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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-s', result)
  26. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  27. def test_run_damoyolo_m(self):
  28. tinynas_object_detection = pipeline(
  29. Tasks.image_object_detection,
  30. model='damo/cv_tinynas_object-detection_damoyolo-m')
  31. result = tinynas_object_detection(
  32. 'data/test/images/image_detection.jpg')
  33. print('damoyolo-m', result)
  34. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  35. def test_run_damoyolo_t(self):
  36. tinynas_object_detection = pipeline(
  37. Tasks.image_object_detection,
  38. model='damo/cv_tinynas_object-detection_damoyolo-t')
  39. result = tinynas_object_detection(
  40. 'data/test/images/image_detection.jpg')
  41. print('damoyolo-t', result)
  42. @unittest.skip('demo compatibility test is only enabled on a needed-basis')
  43. def test_demo_compatibility(self):
  44. self.compatibility_check()
  45. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  46. def test_image_object_detection_auto_pipeline(self):
  47. test_image = 'data/test/images/image_detection.jpg'
  48. tinynas_object_detection = pipeline(
  49. Tasks.image_object_detection,
  50. model='damo/cv_tinynas_object-detection_damoyolo-m')
  51. result = tinynas_object_detection(test_image)
  52. tinynas_object_detection.show_result(test_image, result,
  53. 'demo_ret.jpg')
  54. if __name__ == '__main__':
  55. unittest.main()