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_referring_video_object_segmentation.py 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 ReferringVideoObjectSegmentationTest(unittest.TestCase,
  8. DemoCompatibilityCheck):
  9. def setUp(self) -> None:
  10. self.task = Tasks.referring_video_object_segmentation
  11. self.model_id = 'damo/cv_swin-t_referring_video-object-segmentation'
  12. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  13. def test_referring_video_object_segmentation(self):
  14. input_location = 'data/test/videos/referring_video_object_segmentation_test_video.mp4'
  15. text_queries = [
  16. 'guy in black performing tricks on a bike',
  17. 'a black bike used to perform tricks'
  18. ]
  19. start_pt, end_pt = 4, 14
  20. input_tuple = (input_location, text_queries, start_pt, end_pt)
  21. pp = pipeline(
  22. Tasks.referring_video_object_segmentation, model=self.model_id)
  23. result = pp(input_tuple)
  24. if result:
  25. print(result)
  26. else:
  27. raise ValueError('process error')
  28. @unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
  29. def test_referring_video_object_segmentation_with_default_task(self):
  30. input_location = 'data/test/videos/referring_video_object_segmentation_test_video.mp4'
  31. text_queries = [
  32. 'guy in black performing tricks on a bike',
  33. 'a black bike used to perform tricks'
  34. ]
  35. start_pt, end_pt = 4, 14
  36. input_tuple = (input_location, text_queries, start_pt, end_pt)
  37. pp = pipeline(Tasks.referring_video_object_segmentation)
  38. result = pp(input_tuple)
  39. if result:
  40. print(result)
  41. else:
  42. raise ValueError('process error')
  43. @unittest.skip('demo compatibility test is only enabled on a needed-basis')
  44. def test_demo_compatibility(self):
  45. self.compatibility_check()
  46. if __name__ == '__main__':
  47. unittest.main()