2022-08-31 20:54:20 +08:00
|
|
|
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from modelscope.pipelines import pipeline
|
|
|
|
|
from modelscope.utils.constant import Tasks
|
2022-09-08 14:08:51 +08:00
|
|
|
from modelscope.utils.demo_utils import DemoCompatibilityCheck
|
2022-08-31 20:54:20 +08:00
|
|
|
from modelscope.utils.test_utils import test_level
|
|
|
|
|
|
|
|
|
|
|
2022-09-08 14:08:51 +08:00
|
|
|
class MovieSceneSegmentationTest(unittest.TestCase, DemoCompatibilityCheck):
|
|
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
|
self.task = Tasks.movie_scene_segmentation
|
|
|
|
|
self.model_id = 'damo/cv_resnet50-bert_video-scene-segmentation_movienet'
|
2022-08-31 20:54:20 +08:00
|
|
|
|
|
|
|
|
@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
|
|
|
|
|
def test_movie_scene_segmentation(self):
|
|
|
|
|
input_location = 'data/test/videos/movie_scene_segmentation_test_video.mp4'
|
|
|
|
|
movie_scene_segmentation_pipeline = pipeline(
|
2022-09-08 14:08:51 +08:00
|
|
|
Tasks.movie_scene_segmentation, model=self.model_id)
|
2022-08-31 20:54:20 +08:00
|
|
|
result = movie_scene_segmentation_pipeline(input_location)
|
|
|
|
|
if result:
|
|
|
|
|
print(result)
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError('process error')
|
|
|
|
|
|
|
|
|
|
@unittest.skipUnless(test_level() >= 2, 'skip test in current test level')
|
|
|
|
|
def test_movie_scene_segmentation_with_default_task(self):
|
|
|
|
|
input_location = 'data/test/videos/movie_scene_segmentation_test_video.mp4'
|
|
|
|
|
movie_scene_segmentation_pipeline = pipeline(
|
|
|
|
|
Tasks.movie_scene_segmentation)
|
|
|
|
|
result = movie_scene_segmentation_pipeline(input_location)
|
|
|
|
|
if result:
|
|
|
|
|
print(result)
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError('process error')
|
|
|
|
|
|
2022-09-09 14:56:15 +08:00
|
|
|
@unittest.skip('demo compatibility test is only enabled on a needed-basis')
|
2022-09-08 14:08:51 +08:00
|
|
|
def test_demo_compatibility(self):
|
|
|
|
|
self.compatibility_check()
|
|
|
|
|
|
2022-08-31 20:54:20 +08:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|