diff --git a/modelscope/pipeline_inputs.py b/modelscope/pipeline_inputs.py index 50818dff..adb9fe23 100644 --- a/modelscope/pipeline_inputs.py +++ b/modelscope/pipeline_inputs.py @@ -38,10 +38,10 @@ INPUT_TYPE = { def check_input_type(input_type, input): expected_type = INPUT_TYPE[input_type] - if expected_type == 'cv2.VideoCapture': + if input_type == InputType.VIDEO: # special type checking using class name, to avoid introduction of opencv dependency into fundamental framework. - assert type(input).__name__ == 'VideoCapture',\ - f'invalid input type for {input_type}, expected cv2.VideoCapture but got {type(input)}\n {input}' + assert type(input).__name__ == 'VideoCapture' or isinstance(input, expected_type),\ + f'invalid input type for {input_type}, expected {expected_type} but got {type(input)}\n {input}' else: assert isinstance(input, expected_type), \ f'invalid input type for {input_type}, expected {expected_type} but got {type(input)}\n {input}' diff --git a/tests/pipelines/test_body_3d_keypoints.py b/tests/pipelines/test_body_3d_keypoints.py index 6e671d2e..6f73a243 100644 --- a/tests/pipelines/test_body_3d_keypoints.py +++ b/tests/pipelines/test_body_3d_keypoints.py @@ -39,9 +39,7 @@ class Body3DKeypointsTest(unittest.TestCase, DemoCompatibilityCheck): if not cap.isOpened(): raise Exception('modelscope error: %s cannot be decoded by OpenCV.' % (self.test_video)) - pipeline_input = self.test_video - self.pipeline_inference( - body_3d_keypoints, pipeline_input=pipeline_input) + self.pipeline_inference(body_3d_keypoints, pipeline_input=cap) @unittest.skipUnless(test_level() >= 0, 'skip test in current test level') def test_demo_compatibility(self):