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_face_2d_keypoints.py 1.2 kB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import unittest
  3. import cv2
  4. from modelscope.outputs import OutputKeys
  5. from modelscope.pipelines import pipeline
  6. from modelscope.utils.constant import Tasks
  7. from modelscope.utils.test_utils import test_level
  8. class EasyCVFace2DKeypointsPipelineTest(unittest.TestCase):
  9. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  10. def test_face_2d_keypoints(self):
  11. img_path = 'data/test/images/keypoints_detect/test_img_face_2d_keypoints.png'
  12. model_id = 'damo/cv_mobilenet_face-2d-keypoints_alignment'
  13. face_2d_keypoints_align = pipeline(
  14. task=Tasks.face_2d_keypoints, model=model_id)
  15. output = face_2d_keypoints_align(img_path)[0]
  16. output_keypoints = output[OutputKeys.KEYPOINTS]
  17. output_pose = output[OutputKeys.POSES]
  18. img = cv2.imread(img_path)
  19. img = face_2d_keypoints_align.show_result(
  20. img, output_keypoints, scale=2, save_path='face_keypoints.jpg')
  21. self.assertEqual(output_keypoints.shape[0], 106)
  22. self.assertEqual(output_keypoints.shape[1], 2)
  23. self.assertEqual(output_pose.shape[0], 3)
  24. if __name__ == '__main__':
  25. unittest.main()