mirror of
https://github.com/modelscope/modelscope.git
synced 2026-09-01 19:49:03 +02:00
fix check video type cv2.VideoCapture and add unittest
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11181951
This commit is contained in:
@@ -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}'
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user