Skip to content

Commit 5bf1d8c

Browse files
authored
add coverage (open-mmlab#100)
1 parent 5abd845 commit 5bf1d8c

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

tests/test_api/test_inference.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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)

tests/test_datasets/test_bottom_up_dataset.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ def test_bottom_up_COCO_dataset():
3737
pipeline=[])
3838

3939
assert custom_dataset.num_images == 4
40+
_ = custom_dataset[0]

tests/test_datasets/test_top_down_dataset.py

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_top_down_COCO_dataset():
6969
image_id = 785
7070
assert image_id in custom_dataset.image_set_index
7171
assert len(custom_dataset.image_set_index) == 4
72+
_ = custom_dataset[0]
7273

7374

7475
def test_top_down_OneHand10K_dataset():
@@ -114,6 +115,7 @@ def test_top_down_OneHand10K_dataset():
114115

115116
assert custom_dataset.test_mode is False
116117
assert custom_dataset.num_images == 4
118+
_ = custom_dataset[0]
117119

118120

119121
def test_top_down_MPII_dataset():
@@ -151,6 +153,7 @@ def test_top_down_MPII_dataset():
151153
pipeline=[])
152154

153155
assert len(custom_dataset) == 5
156+
_ = custom_dataset[0]
154157

155158

156159
def test_top_down_MPII_TRB_dataset():
@@ -188,6 +191,7 @@ def test_top_down_MPII_TRB_dataset():
188191
test_mode=True)
189192

190193
assert custom_dataset.test_mode is True
194+
_ = custom_dataset[0]
191195

192196

193197
def test_top_down_AIC_dataset():
@@ -252,3 +256,4 @@ def test_top_down_AIC_dataset():
252256
image_id = 1
253257
assert image_id in custom_dataset.image_set_index
254258
assert len(custom_dataset.image_set_index) == 3
259+
_ = custom_dataset[0]

0 commit comments

Comments
 (0)