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_common.py 904 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. from modelscope.preprocessors import PREPROCESSORS, Compose, Preprocessor
  4. class ComposeTest(unittest.TestCase):
  5. def test_compose(self):
  6. @PREPROCESSORS.register_module()
  7. class Tmp1(Preprocessor):
  8. def __call__(self, input):
  9. input['tmp1'] = 'tmp1'
  10. return input
  11. @PREPROCESSORS.register_module()
  12. class Tmp2(Preprocessor):
  13. def __call__(self, input):
  14. input['tmp2'] = 'tmp2'
  15. return input
  16. pipeline = [
  17. dict(type='Tmp1'),
  18. dict(type='Tmp2'),
  19. ]
  20. trans = Compose(pipeline)
  21. input = {}
  22. output = trans(input)
  23. self.assertEqual(output['tmp1'], 'tmp1')
  24. self.assertEqual(output['tmp2'], 'tmp2')
  25. if __name__ == '__main__':
  26. unittest.main()