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_video_single_object_tracking.py 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. from modelscope.outputs import OutputKeys
  4. from modelscope.pipelines import pipeline
  5. from modelscope.utils.constant import Tasks
  6. from modelscope.utils.cv.image_utils import show_video_tracking_result
  7. from modelscope.utils.demo_utils import DemoCompatibilityCheck
  8. from modelscope.utils.test_utils import test_level
  9. class SingleObjectTracking(unittest.TestCase, DemoCompatibilityCheck):
  10. def setUp(self) -> None:
  11. self.task = Tasks.video_single_object_tracking
  12. self.model_id = 'damo/cv_vitb_video-single-object-tracking_ostrack'
  13. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  14. def test_run_end2end(self):
  15. video_single_object_tracking = pipeline(
  16. Tasks.video_single_object_tracking, model=self.model_id)
  17. video_path = 'data/test/videos/dog.avi'
  18. init_bbox = [414, 343, 514, 449] # [x1, y1, x2, y2]
  19. result = video_single_object_tracking((video_path, init_bbox))
  20. print('result is : ', result[OutputKeys.BOXES])
  21. show_video_tracking_result(video_path, result[OutputKeys.BOXES],
  22. './tracking_result.avi')
  23. @unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
  24. def test_run_modelhub_default_model(self):
  25. video_single_object_tracking = pipeline(
  26. Tasks.video_single_object_tracking)
  27. video_path = 'data/test/videos/dog.avi'
  28. init_bbox = [414, 343, 514, 449] # [x1, y1, x2, y2]
  29. result = video_single_object_tracking((video_path, init_bbox))
  30. print('result is : ', result[OutputKeys.BOXES])
  31. @unittest.skip('demo compatibility test is only enabled on a needed-basis')
  32. def test_demo_compatibility(self):
  33. self.compatibility_check()
  34. if __name__ == '__main__':
  35. unittest.main()