|
| 1 | +from mmpose.apis import (inference_bottom_up_pose_model, |
| 2 | + inference_top_down_pose_model, init_pose_model, |
| 3 | + vis_pose_result) |
| 4 | + |
| 5 | + |
| 6 | +def test_top_down_demo(): |
| 7 | + skeleton = [[16, 14], [14, 12], [17, 15], [15, 13], [12, 13], [6, 12], |
| 8 | + [7, 13], [6, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 3], |
| 9 | + [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]] |
| 10 | + |
| 11 | + # build the pose model from a config file and a checkpoint file |
| 12 | + pose_model = init_pose_model( |
| 13 | + 'configs/top_down/resnet/coco/res50_coco_256x192.py', |
| 14 | + None, |
| 15 | + device='cpu') |
| 16 | + |
| 17 | + image_name = 'tests/data/coco/000000000785.jpg' |
| 18 | + # test a single image, with a list of bboxes. |
| 19 | + pose_results = inference_top_down_pose_model( |
| 20 | + pose_model, image_name, [[50, 50, 50, 100]], format='xywh') |
| 21 | + |
| 22 | + # show the results |
| 23 | + vis_pose_result(pose_model, image_name, pose_results, skeleton=skeleton) |
| 24 | + |
| 25 | + |
| 26 | +def test_bottom_up_demo(): |
| 27 | + skeleton = [[16, 14], [14, 12], [17, 15], [15, 13], [12, 13], [6, 12], |
| 28 | + [7, 13], [6, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 3], |
| 29 | + [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]] |
| 30 | + |
| 31 | + # build the pose model from a config file and a checkpoint file |
| 32 | + pose_model = init_pose_model( |
| 33 | + 'configs/bottom_up/resnet/coco/res50_coco_512x512.py', |
| 34 | + None, |
| 35 | + device='cpu') |
| 36 | + |
| 37 | + image_name = 'tests/data/coco/000000000785.jpg' |
| 38 | + |
| 39 | + pose_results = inference_bottom_up_pose_model(pose_model, image_name) |
| 40 | + |
| 41 | + # show the results |
| 42 | + vis_pose_result(pose_model, image_name, pose_results, skeleton=skeleton) |
0 commit comments