Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions configs/_base_/datasets/coco_openpose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
dataset_info = dict(
dataset_name='coco_openpose',
paper_info=dict(
author='Zhe, Cao and Tomas, Simon and '
'Shih-En, Wei and Yaser, Sheikh',
title='OpenPose: Realtime Multi-Person 2D Pose '
'Estimation using Part Affinity Fields',
container='IEEE Transactions on Pattern Analysis '
'and Machine Intelligence',
year='2019',
homepage='https://github.com/CMU-Perceptual-Computing-Lab/openpose/',
),
keypoint_info={
0:
dict(name='nose', id=0, color=[255, 0, 85], type='upper', swap=''),
1:
dict(name='neck', id=1, color=[255, 0, 0], type='upper', swap=''),
2:
dict(
name='right_shoulder',
id=2,
color=[255, 85, 0],
type='upper',
swap='left_shoulder'),
3:
dict(
name='right_elbow',
id=3,
color=[255, 170, 0],
type='upper',
swap='left_elbow'),
4:
dict(
name='right_wrist',
id=4,
color=[255, 255, 0],
type='upper',
swap='left_wrist'),
5:
dict(
name='left_shoulder',
id=5,
color=[170, 255, 0],
type='upper',
swap='right_shoulder'),
6:
dict(
name='left_elbow',
id=6,
color=[85, 255, 0],
type='upper',
swap='right_elbow'),
7:
dict(
name='left_wrist',
id=7,
color=[0, 255, 0],
type='upper',
swap='right_wrist'),
8:
dict(
name='right_hip',
id=8,
color=[255, 0, 170],
type='lower',
swap='left_hip'),
9:
dict(
name='right_knee',
id=9,
color=[255, 0, 255],
type='lower',
swap='left_knee'),
10:
dict(
name='right_ankle',
id=10,
color=[170, 0, 255],
type='lower',
swap='left_ankle'),
11:
dict(
name='left_hip',
id=11,
color=[85, 255, 0],
type='lower',
swap='right_hip'),
12:
dict(
name='left_knee',
id=12,
color=[0, 0, 255],
type='lower',
swap='right_knee'),
13:
dict(
name='left_ankle',
id=13,
color=[0, 85, 255],
type='lower',
swap='right_ankle'),
14:
dict(
name='right_eye',
id=14,
color=[0, 255, 170],
type='upper',
swap='left_eye'),
15:
dict(
name='left_eye',
id=15,
color=[0, 255, 255],
type='upper',
swap='right_eye'),
16:
dict(
name='right_ear',
id=16,
color=[0, 170, 255],
type='upper',
swap='left_ear'),
17:
dict(
name='left_ear',
id=17,
color=[0, 170, 255],
type='upper',
swap='right_ear'),
},
skeleton_info={
0: dict(link=('neck', 'right_shoulder'), id=0, color=[255, 0, 85]),
1: dict(link=('neck', 'left_shoulder'), id=1, color=[255, 0, 0]),
2:
dict(link=('right_shoulder', 'right_elbow'), id=2, color=[255, 85, 0]),
3:
dict(link=('right_elbow', 'right_wrist'), id=3, color=[255, 170, 0]),
4:
dict(link=('left_shoulder', 'left_elbow'), id=4, color=[255, 255, 0]),
5: dict(link=('left_elbow', 'left_wrist'), id=5, color=[170, 255, 0]),
6: dict(link=('neck', 'right_hip'), id=6, color=[85, 255, 0]),
7: dict(link=('right_hip', 'right_knee'), id=7, color=[0, 255, 0]),
8: dict(link=('right_knee', 'right_ankle'), id=8, color=[0, 255, 85]),
9: dict(link=('neck', 'left_hip'), id=9, color=[0, 255, 170]),
10: dict(link=('left_hip', 'left_knee'), id=10, color=[0, 255, 225]),
11: dict(link=('left_knee', 'left_ankle'), id=11, color=[0, 170, 255]),
12: dict(link=('neck', 'nose'), id=12, color=[0, 85, 255]),
13: dict(link=('nose', 'right_eye'), id=13, color=[0, 0, 255]),
14: dict(link=('right_eye', 'right_ear'), id=14, color=[255, 0, 170]),
15: dict(link=('nose', 'left_eye'), id=15, color=[170, 0, 255]),
16: dict(link=('left_eye', 'left_ear'), id=16, color=[255, 0, 255]),
},
joint_weights=[1.] * 18,
sigmas=[
0.026, 0.025, 0.025, 0.035, 0.035, 0.079, 0.079, 0.072, 0.072, 0.062,
0.062, 0.107, 0.107, 0.087, 0.087, 0.089, 0.089, 0.082
])
32 changes: 31 additions & 1 deletion demo/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ def parse_args():
action='store_true',
default=False,
help='Whether to show the index of keypoints')
parser.add_argument(
'--skeleton-style',
default='mmpose',
type=str,
choices=['mmpose', 'openpose'],
help='Skeleton style selection')
parser.add_argument(
'--kpt-thr',
type=float,
default=0.3,
help='Visualizing keypoint thresholds')
parser.add_argument(
'--radius',
type=int,
default=3,
help='Keypoint radius for visualization')
parser.add_argument(
'--thickness',
type=int,
default=1,
help='Link thickness for visualization')
parser.add_argument(
'--alpha', type=float, default=0.8, help='The transparency of bboxes')
parser.add_argument(
'--show',
action='store_true',
Expand All @@ -50,8 +73,13 @@ def main():
cfg_options=cfg_options)

# init visualizer
model.cfg.visualizer.radius = args.radius
model.cfg.visualizer.alpha = args.alpha
model.cfg.visualizer.line_width = args.thickness

visualizer = VISUALIZERS.build(model.cfg.visualizer)
visualizer.set_dataset_meta(model.dataset_meta)
visualizer.set_dataset_meta(
model.dataset_meta, skeleton_style=args.skeleton_style)

# inference a single image
batch_results = inference_topdown(model, args.img)
Expand All @@ -65,8 +93,10 @@ def main():
data_sample=results,
draw_gt=False,
draw_bbox=True,
kpt_thr=args.kpt_thr,
draw_heatmap=args.draw_heatmap,
show_kpt_idx=args.show_kpt_idx,
skeleton_style=args.skeleton_style,
show=args.show,
out_file=args.out_file)

Expand Down
21 changes: 18 additions & 3 deletions demo/topdown_demo_with_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def process_one_image(args, img_path, detector, pose_estimator, visualizer,
draw_heatmap=args.draw_heatmap,
draw_bbox=args.draw_bbox,
show_kpt_idx=args.show_kpt_idx,
skeleton_style=args.skeleton_style,
show=args.show,
wait_time=show_interval,
out_file=out_file,
kpt_score_thr=args.kpt_thr)
kpt_thr=args.kpt_thr)

# if there is no instance detected, return None
return data_samples.get('pred_instances', None)
Expand Down Expand Up @@ -110,7 +111,10 @@ def main():
default=0.3,
help='IoU threshold for bounding box NMS')
parser.add_argument(
'--kpt-thr', type=float, default=0.3, help='Keypoint score threshold')
'--kpt-thr',
type=float,
default=0.3,
help='Visualizing keypoint thresholds')
parser.add_argument(
'--draw-heatmap',
action='store_true',
Expand All @@ -121,6 +125,12 @@ def main():
action='store_true',
default=False,
help='Whether to show the index of keypoints')
parser.add_argument(
'--skeleton-style',
default='mmpose',
type=str,
choices=['mmpose', 'openpose'],
help='Skeleton style selection')
parser.add_argument(
'--radius',
type=int,
Expand All @@ -131,6 +141,8 @@ def main():
type=int,
default=1,
help='Link thickness for visualization')
parser.add_argument(
'--alpha', type=float, default=0.8, help='The transparency of bboxes')
parser.add_argument(
'--draw-bbox', action='store_true', help='Draw bboxes of instances')

Expand Down Expand Up @@ -164,11 +176,14 @@ def main():

# init visualizer
pose_estimator.cfg.visualizer.radius = args.radius
pose_estimator.cfg.visualizer.alpha = args.alpha
pose_estimator.cfg.visualizer.line_width = args.thickness

visualizer = VISUALIZERS.build(pose_estimator.cfg.visualizer)
# the dataset_meta is loaded from the checkpoint and
# then pass to the model in init_pose_estimator
visualizer.set_dataset_meta(pose_estimator.dataset_meta)
visualizer.set_dataset_meta(
pose_estimator.dataset_meta, skeleton_style=args.skeleton_style)

input_type = mimetypes.guess_type(args.input)[0].split('/')[0]
if input_type == 'image':
Expand Down
Loading