Skip to content

Commit 283ca48

Browse files
Merge e60b836 into 71d74de
2 parents 71d74de + e60b836 commit 283ca48

File tree

7 files changed

+357
-113
lines changed

7 files changed

+357
-113
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
dataset_info = dict(
2+
dataset_name='coco_openpose',
3+
paper_info=dict(
4+
author='Zhe, Cao and Tomas, Simon and '
5+
'Shih-En, Wei and Yaser, Sheikh',
6+
title='OpenPose: Realtime Multi-Person 2D Pose '
7+
'Estimation using Part Affinity Fields',
8+
container='IEEE Transactions on Pattern Analysis '
9+
'and Machine Intelligence',
10+
year='2019',
11+
homepage='https://github.com/CMU-Perceptual-Computing-Lab/openpose/',
12+
),
13+
keypoint_info={
14+
0:
15+
dict(name='nose', id=0, color=[255, 0, 85], type='upper', swap=''),
16+
1:
17+
dict(name='neck', id=1, color=[255, 0, 0], type='upper', swap=''),
18+
2:
19+
dict(
20+
name='right_shoulder',
21+
id=2,
22+
color=[255, 85, 0],
23+
type='upper',
24+
swap='left_shoulder'),
25+
3:
26+
dict(
27+
name='right_elbow',
28+
id=3,
29+
color=[255, 170, 0],
30+
type='upper',
31+
swap='left_elbow'),
32+
4:
33+
dict(
34+
name='right_wrist',
35+
id=4,
36+
color=[255, 255, 0],
37+
type='upper',
38+
swap='left_wrist'),
39+
5:
40+
dict(
41+
name='left_shoulder',
42+
id=5,
43+
color=[170, 255, 0],
44+
type='upper',
45+
swap='right_shoulder'),
46+
6:
47+
dict(
48+
name='left_elbow',
49+
id=6,
50+
color=[85, 255, 0],
51+
type='upper',
52+
swap='right_elbow'),
53+
7:
54+
dict(
55+
name='left_wrist',
56+
id=7,
57+
color=[0, 255, 0],
58+
type='upper',
59+
swap='right_wrist'),
60+
8:
61+
dict(
62+
name='right_hip',
63+
id=8,
64+
color=[255, 0, 170],
65+
type='lower',
66+
swap='left_hip'),
67+
9:
68+
dict(
69+
name='right_knee',
70+
id=9,
71+
color=[255, 0, 255],
72+
type='lower',
73+
swap='left_knee'),
74+
10:
75+
dict(
76+
name='right_ankle',
77+
id=10,
78+
color=[170, 0, 255],
79+
type='lower',
80+
swap='left_ankle'),
81+
11:
82+
dict(
83+
name='left_hip',
84+
id=11,
85+
color=[85, 255, 0],
86+
type='lower',
87+
swap='right_hip'),
88+
12:
89+
dict(
90+
name='left_knee',
91+
id=12,
92+
color=[0, 0, 255],
93+
type='lower',
94+
swap='right_knee'),
95+
13:
96+
dict(
97+
name='left_ankle',
98+
id=13,
99+
color=[0, 85, 255],
100+
type='lower',
101+
swap='right_ankle'),
102+
14:
103+
dict(
104+
name='right_eye',
105+
id=14,
106+
color=[0, 255, 170],
107+
type='upper',
108+
swap='left_eye'),
109+
15:
110+
dict(
111+
name='left_eye',
112+
id=15,
113+
color=[0, 255, 255],
114+
type='upper',
115+
swap='right_eye'),
116+
16:
117+
dict(
118+
name='right_ear',
119+
id=16,
120+
color=[0, 170, 255],
121+
type='upper',
122+
swap='left_ear'),
123+
17:
124+
dict(
125+
name='left_ear',
126+
id=17,
127+
color=[0, 170, 255],
128+
type='upper',
129+
swap='right_ear'),
130+
},
131+
skeleton_info={
132+
0: dict(link=('neck', 'right_shoulder'), id=0, color=[255, 0, 85]),
133+
1: dict(link=('neck', 'left_shoulder'), id=1, color=[255, 0, 0]),
134+
2:
135+
dict(link=('right_shoulder', 'right_elbow'), id=2, color=[255, 85, 0]),
136+
3:
137+
dict(link=('right_elbow', 'right_wrist'), id=3, color=[255, 170, 0]),
138+
4:
139+
dict(link=('left_shoulder', 'left_elbow'), id=4, color=[255, 255, 0]),
140+
5: dict(link=('left_elbow', 'left_wrist'), id=5, color=[170, 255, 0]),
141+
6: dict(link=('neck', 'right_hip'), id=6, color=[85, 255, 0]),
142+
7: dict(link=('right_hip', 'right_knee'), id=7, color=[0, 255, 0]),
143+
8: dict(link=('right_knee', 'right_ankle'), id=8, color=[0, 255, 85]),
144+
9: dict(link=('neck', 'left_hip'), id=9, color=[0, 255, 170]),
145+
10: dict(link=('left_hip', 'left_knee'), id=10, color=[0, 255, 225]),
146+
11: dict(link=('left_knee', 'left_ankle'), id=11, color=[0, 170, 255]),
147+
12: dict(link=('neck', 'nose'), id=12, color=[0, 85, 255]),
148+
13: dict(link=('nose', 'right_eye'), id=13, color=[0, 0, 255]),
149+
14: dict(link=('right_eye', 'right_ear'), id=14, color=[255, 0, 170]),
150+
15: dict(link=('nose', 'left_eye'), id=15, color=[170, 0, 255]),
151+
16: dict(link=('left_eye', 'left_ear'), id=16, color=[255, 0, 255]),
152+
},
153+
joint_weights=[1.] * 18,
154+
sigmas=[
155+
0.026, 0.025, 0.025, 0.035, 0.035, 0.079, 0.079, 0.072, 0.072, 0.062,
156+
0.062, 0.107, 0.107, 0.087, 0.087, 0.089, 0.089, 0.082
157+
])

demo/image_demo.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ def parse_args():
2525
action='store_true',
2626
default=False,
2727
help='Whether to show the index of keypoints')
28+
parser.add_argument(
29+
'--skeleton-style',
30+
default='mmpose',
31+
type=str,
32+
choices=['mmpose', 'openpose'],
33+
help='Skeleton style selection')
34+
parser.add_argument(
35+
'--kpt-thr',
36+
type=float,
37+
default=0.3,
38+
help='Visualizing keypoint thresholds')
39+
parser.add_argument(
40+
'--radius',
41+
type=int,
42+
default=3,
43+
help='Keypoint radius for visualization')
44+
parser.add_argument(
45+
'--thickness',
46+
type=int,
47+
default=1,
48+
help='Link thickness for visualization')
49+
parser.add_argument(
50+
'--alpha', type=float, default=0.8, help='The transparency of bboxes')
2851
parser.add_argument(
2952
'--show',
3053
action='store_true',
@@ -50,8 +73,13 @@ def main():
5073
cfg_options=cfg_options)
5174

5275
# init visualizer
76+
model.cfg.visualizer.radius = args.radius
77+
model.cfg.visualizer.alpha = args.alpha
78+
model.cfg.visualizer.line_width = args.thickness
79+
5380
visualizer = VISUALIZERS.build(model.cfg.visualizer)
54-
visualizer.set_dataset_meta(model.dataset_meta)
81+
visualizer.set_dataset_meta(
82+
model.dataset_meta, skeleton_style=args.skeleton_style)
5583

5684
# inference a single image
5785
batch_results = inference_topdown(model, args.img)
@@ -65,8 +93,10 @@ def main():
6593
data_sample=results,
6694
draw_gt=False,
6795
draw_bbox=True,
96+
kpt_thr=args.kpt_thr,
6897
draw_heatmap=args.draw_heatmap,
6998
show_kpt_idx=args.show_kpt_idx,
99+
skeleton_style=args.skeleton_style,
70100
show=args.show,
71101
out_file=args.out_file)
72102

demo/topdown_demo_with_mmdet.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ def process_one_image(args, img_path, detector, pose_estimator, visualizer,
5555
draw_heatmap=args.draw_heatmap,
5656
draw_bbox=args.draw_bbox,
5757
show_kpt_idx=args.show_kpt_idx,
58+
skeleton_style=args.skeleton_style,
5859
show=args.show,
5960
wait_time=show_interval,
6061
out_file=out_file,
61-
kpt_score_thr=args.kpt_thr)
62+
kpt_thr=args.kpt_thr)
6263

6364
# if there is no instance detected, return None
6465
return data_samples.get('pred_instances', None)
@@ -110,7 +111,10 @@ def main():
110111
default=0.3,
111112
help='IoU threshold for bounding box NMS')
112113
parser.add_argument(
113-
'--kpt-thr', type=float, default=0.3, help='Keypoint score threshold')
114+
'--kpt-thr',
115+
type=float,
116+
default=0.3,
117+
help='Visualizing keypoint thresholds')
114118
parser.add_argument(
115119
'--draw-heatmap',
116120
action='store_true',
@@ -121,6 +125,12 @@ def main():
121125
action='store_true',
122126
default=False,
123127
help='Whether to show the index of keypoints')
128+
parser.add_argument(
129+
'--skeleton-style',
130+
default='mmpose',
131+
type=str,
132+
choices=['mmpose', 'openpose'],
133+
help='Skeleton style selection')
124134
parser.add_argument(
125135
'--radius',
126136
type=int,
@@ -131,6 +141,8 @@ def main():
131141
type=int,
132142
default=1,
133143
help='Link thickness for visualization')
144+
parser.add_argument(
145+
'--alpha', type=float, default=0.8, help='The transparency of bboxes')
134146
parser.add_argument(
135147
'--draw-bbox', action='store_true', help='Draw bboxes of instances')
136148

@@ -164,11 +176,14 @@ def main():
164176

165177
# init visualizer
166178
pose_estimator.cfg.visualizer.radius = args.radius
179+
pose_estimator.cfg.visualizer.alpha = args.alpha
167180
pose_estimator.cfg.visualizer.line_width = args.thickness
181+
168182
visualizer = VISUALIZERS.build(pose_estimator.cfg.visualizer)
169183
# the dataset_meta is loaded from the checkpoint and
170184
# then pass to the model in init_pose_estimator
171-
visualizer.set_dataset_meta(pose_estimator.dataset_meta)
185+
visualizer.set_dataset_meta(
186+
pose_estimator.dataset_meta, skeleton_style=args.skeleton_style)
172187

173188
input_type = mimetypes.guess_type(args.input)[0].split('/')[0]
174189
if input_type == 'image':

mmpose/apis/inferencers/base_mmpose_inferencer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def visualize(self,
314314
show=show,
315315
wait_time=wait_time,
316316
out_file=out_file,
317-
kpt_score_thr=kpt_thr)
317+
kpt_thr=kpt_thr)
318318
results.append(visualization)
319319

320320
if show and not hasattr(self, '_window_close_cid'):

mmpose/engine/hooks/visualization_hook.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def __init__(
5050
self,
5151
enable: bool = False,
5252
interval: int = 50,
53-
score_thr: float = 0.3,
53+
kpt_thr: float = 0.3,
5454
show: bool = False,
5555
wait_time: float = 0.,
5656
out_dir: Optional[str] = None,
5757
backend_args: Optional[dict] = None,
5858
):
5959
self._visualizer: Visualizer = Visualizer.get_current_instance()
6060
self.interval = interval
61-
self.score_thr = score_thr
61+
self.kpt_thr = kpt_thr
6262
self.show = show
6363
if self.show:
6464
# No need to think about vis backends.
@@ -112,7 +112,7 @@ def after_val_iter(self, runner: Runner, batch_idx: int, data_batch: dict,
112112
draw_heatmap=True,
113113
show=self.show,
114114
wait_time=self.wait_time,
115-
kpt_score_thr=self.score_thr,
115+
kpt_thr=self.kpt_thr,
116116
step=total_curr_iter)
117117

118118
def after_test_iter(self, runner: Runner, batch_idx: int, data_batch: dict,
@@ -163,6 +163,6 @@ def after_test_iter(self, runner: Runner, batch_idx: int, data_batch: dict,
163163
draw_bbox=True,
164164
draw_heatmap=True,
165165
wait_time=self.wait_time,
166-
kpt_score_thr=self.score_thr,
166+
kpt_thr=self.kpt_thr,
167167
out_file=out_file,
168168
step=self._test_index)

0 commit comments

Comments
 (0)