Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 3d human pose demo argument use-multi-frames #2601

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 4 additions & 32 deletions demo/body3d_pose_lifter_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from mmengine.logging import print_log

from mmpose.apis import (_track_by_iou, _track_by_oks, collect_multi_frames,
from mmpose.apis import (_track_by_iou, _track_by_oks,
convert_keypoint_definition, extract_pose_sequence,
inference_pose_lifter_model, inference_topdown,
init_model)
Expand Down Expand Up @@ -120,12 +120,6 @@ def parse_args():
type=int,
default=3,
help='Keypoint radius for visualization')
parser.add_argument(
'--use-multi-frames',
action='store_true',
default=False,
help='Whether to use multi frames for inference in the 2D pose'
'detection stage. Default: False.')
parser.add_argument(
'--online',
action='store_true',
Expand All @@ -139,9 +133,8 @@ def parse_args():


def process_one_image(args, detector, frame, frame_idx, pose_estimator,
pose_est_frame, pose_est_results_last,
pose_est_results_list, next_id, pose_lifter,
visualize_frame, visualizer):
pose_est_results_last, pose_est_results_list, next_id,
pose_lifter, visualize_frame, visualizer):
"""Visualize detected and predicted keypoints of one image.

Pipeline of this function:
Expand Down Expand Up @@ -189,8 +182,6 @@ def process_one_image(args, detector, frame, frame_idx, pose_estimator,
frame (np.ndarray): The image frame read from input image or video.
frame_idx (int): The index of current frame.
pose_estimator (TopdownPoseEstimator): The pose estimator for 2d pose.
pose_est_frame (np.ndarray | list(np.ndarray)): The frames for pose
estimation.
pose_est_results_last (list(PoseDataSample)): The results of pose
estimation from the last frame for tracking instances.
pose_est_results_list (list(list(PoseDataSample))): The list of all
Expand Down Expand Up @@ -228,8 +219,7 @@ def process_one_image(args, detector, frame, frame_idx, pose_estimator,
pred_instance.scores > args.bbox_thr)]

# estimate pose results for current image
pose_est_results = inference_topdown(pose_estimator, pose_est_frame,
bboxes)
pose_est_results = inference_topdown(pose_estimator, frame, bboxes)

if args.use_oks_tracking:
_track = partial(_track_by_oks)
Expand Down Expand Up @@ -397,12 +387,6 @@ def main():
det_dataset_link_color = pose_estimator.dataset_meta.get(
'skeleton_link_colors', None)

# frame index offsets for inference, used in multi-frame inference setting
if args.use_multi_frames:
assert 'frame_indices' in pose_estimator.cfg.test_dataloader.dataset
indices = pose_estimator.cfg.test_dataloader.dataset[
'frame_indices_test']

pose_lifter = init_model(
args.pose_lifter_config,
args.pose_lifter_checkpoint,
Expand All @@ -412,10 +396,6 @@ def main():
'Only "PoseLifter" model is supported for the 2nd stage ' \
'(2D-to-3D lifting)'

if args.use_multi_frames:
assert 'frame_indices_test' in pose_estimator.cfg.data.test.data_cfg
indices = pose_estimator.cfg.data.test.data_cfg['frame_indices_test']

pose_lifter.cfg.visualizer.radius = args.radius
pose_lifter.cfg.visualizer.line_width = args.thickness
pose_lifter.cfg.visualizer.det_kpt_color = det_kpt_color
Expand Down Expand Up @@ -459,7 +439,6 @@ def main():
frame=frame,
frame_idx=0,
pose_estimator=pose_estimator,
pose_est_frame=frame,
pose_est_results_last=[],
pose_est_results_list=pose_est_results_list,
next_id=0,
Expand Down Expand Up @@ -503,12 +482,6 @@ def main():
pose_est_results_last = pose_est_results

# First stage: 2D pose detection
pose_est_frame = frame
if args.use_multi_frames:
frames = collect_multi_frames(video, frame_idx, indices,
args.online)
pose_est_frame = frames

# make person results for current image
(pose_est_results, pose_est_results_list, pred_3d_instances,
next_id) = process_one_image(
Expand All @@ -517,7 +490,6 @@ def main():
frame=frame,
frame_idx=frame_idx,
pose_estimator=pose_estimator,
pose_est_frame=pose_est_frame,
pose_est_results_last=pose_est_results_last,
pose_est_results_list=pose_est_results_list,
next_id=next_id,
Expand Down
7 changes: 2 additions & 5 deletions demo/docs/en/3d_human_pose_demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ ${MMPOSE_CHECKPOINT_FILE_3D} \
[--show-interval ${INTERVAL}] \
[--thickness ${THICKNESS}] \
[--radius ${RADIUS}] \
[--use-multi-frames] \
[--online]
```

Note that

1. `${VIDEO_PATH}` can be the local path or **URL** link to video file.

2. You can turn on the `[--use-multi-frames]` option to use multi frames for inference in the 2D pose detection stage.

3. If the `[--online]` option is set to **True**, future frame information can **not** be used when using multi frames for inference in the 2D pose detection stage.
2. If the `[--online]` option is set to **True**, future frame information can **not** be used when using multi frames for inference in the 2D pose detection stage.

Examples:

Expand Down Expand Up @@ -73,7 +70,7 @@ configs/body_3d_keypoint/pose_lift/h36m/pose-lift_videopose3d-243frm-supv-cpn-ft
https://download.openmmlab.com/mmpose/body3d/videopose/videopose_h36m_243frames_fullconv_supervised_cpn_ft-88f5abbb_20210527.pth \
--input https://user-images.githubusercontent.com/87690686/164970135-b14e424c-765a-4180-9bc8-fa8d6abc5510.mp4 \
--output-root vis_results \
--use-multi-frames --online
--online
```

### 3D Human Pose Demo with Inferencer
Expand Down
Loading