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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. input_tuple = (input_location, text_queries)
  20. pp = pipeline(
  21. Tasks.referring_video_object_segmentation, model=self.model_id)
  22. result = pp(input_tuple)
  23. if result:
  24. print(result)
  25. else:
  26. raise ValueError('process error')
  27. @unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
  28. def test_referring_video_object_segmentation_with_default_task(self):
  29. input_location = 'data/test/videos/referring_video_object_segmentation_test_video.mp4'
  30. text_queries = [
  31. 'guy in black performing tricks on a bike',
  32. 'a black bike used to perform tricks'
  33. ]
  34. input_tuple = (input_location, text_queries)
  35. pp = pipeline(Tasks.referring_video_object_segmentation)
  36. result = pp(input_tuple)
  37. if result:
  38. print(result)
  39. else:
  40. raise ValueError('process error')
  41. @unittest.skip('demo compatibility test is only enabled on a needed-basis')
  42. def test_demo_compatibility(self):
  43. self.compatibility_check()
  44. if __name__ == '__main__':
  45. unittest.main()