open-mmlab / mmpose

OpenMMLab Pose Estimation Toolbox and Benchmark.
https://mmpose.readthedocs.io/en/latest/
Apache License 2.0
5.86k stars 1.25k forks source link

How to add 2D_hand key_point detection in webcam_api_demo[Bug] #2377

Closed ChenZhenGui closed 1 year ago

ChenZhenGui commented 1 year ago

Prerequisite

Environment

OrderedDict([('sys.platform', 'win32'), ('Python', '3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]'), ('CUDA available', True), ('numpy_random_seed', 2147483648), ('GPU 0', 'NV IDIA GeForce GTX 1650'), ('CUDA_HOME', 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4'), ('NVCC', 'Cuda compilation tools, release 11.4, V11.4.100'), ('MSVC', '用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30143 版'), ('GCC', 'n/a'), ('PyTorch', '1.8.0+cu111'), ('PyTorch compiling details', 'PyTorch built with:\n - C++ Version: 199711\n - MSVC 192829337\n - Intel(R) Math Kernel Library Versi on 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications\n - Intel(R) MKL-DNN v1.7.0 (Git Hash 7aed236906b1f7a05c0917e5257a1af05e9ff683)\n - OpenMP 2019\n - CPU capability usage: AVX2\n

Reproduces the problem - code sample

this is my human_pose.py:

Copyright (c) OpenMMLab. All rights reserved.

executor_cfg = dict(

Basic configurations of the executor

name='Pose Estimation',
camera_id=0,
# Define nodes.
# The configuration of a node usually includes:
#   1. 'type': Node class name
#   2. 'name': Node name
#   3. I/O buffers (e.g. 'input_buffer', 'output_buffer'): specify the
#       input and output buffer names. This may depend on the node class.
#   4. 'enable_key': assign a hot-key to toggle enable/disable this node.
#       This may depend on the node class.
#   5. Other class-specific arguments
nodes=[
    # 'DetectorNode':
    # This node performs object detection from the frame image using an
    # MMDetection model.
    dict(
        type='DetectorNode',
        name='detector',
        model_config='projects/rtmpose/rtmdet/person/'
        'rtmdet_nano_320-8xb32_coco-person.py',
        model_checkpoint='https://download.openmmlab.com/mmpose/v1/'
        'projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth',  # noqa
        input_buffer='_input_',  # `_input_` is an executor-reserved buffer
        output_buffer='det_result'),
    # 'TopdownPoseEstimatorNode':
    # This node performs keypoint detection from the frame image using an
    # MMPose top-down model. Detection results is needed.
    dict(
        type='TopdownPoseEstimatorNode',
        name='human pose estimator',
        model_config='D:/mmpose/configs/body_2d_keypoint/topdown_heatmap/coco/mobilevit_coco-256x192.py',
        model_checkpoint='D:/mmpose/AP_epoch_300.pth',  # noqa
        labels=['person'],
        input_buffer='det_result',
        output_buffer='human_pose'),
    dict(
        type='TopdownPoseEstimatorNode',
        name='hand pose estimator',
        model_config='D:/mmpose/configs/hand_2d_keypoint/topdown_heatmap/coco_wholebody_hand/td-hm_hrnetv2-w18_dark-8xb32-210e_coco-wholebody-hand-256x256.py',
        model_checkpoint='D:/mmpose/hrnetv2_w18_coco_wholebody_hand_256x256_dark-a9228c9c_20210908.pth',  # noqa
        labels=['hand'],
        input_buffer='human_pose',
        output_buffer='hand_pose'),
    # 'ObjectAssignerNode':
    # This node binds the latest model inference result with the current
    # frame. (This means the frame image and inference result may be
    # asynchronous).
    dict(
        type='ObjectAssignerNode',
        name='object assigner',
        frame_buffer='_frame_',  # `_frame_` is an executor-reserved buffer
        object_buffer='hand_pose',
        output_buffer='frame'),
    # 'ObjectVisualizerNode':
    # This node draw the pose visualization result in the frame image.
    # Pose results is needed.
    dict(
        type='ObjectVisualizerNode',
        name='object visualizer',
        enable_key='v',
        enable=True,
        show_bbox=True,
        must_have_keypoint=False,
        show_keypoint=True,
        input_buffer='frame',
        output_buffer='vis'),
    # 'NoticeBoardNode':
    # This node show a notice board with given content, e.g. help
    # information.
    dict(
        type='NoticeBoardNode',
        name='instruction',
        enable_key='h',
        enable=True,
        input_buffer='vis',
        output_buffer='vis_notice',
        content_lines=[
            'This is a demo for pose visualization and simple image '
            'effects. Have fun!', '', 'Hot-keys:',
            '"v": Pose estimation result visualization',
            '"h": Show help information',
            '"m": Show diagnostic information', '"q": Exit'
        ],
    ),
    # 'MonitorNode':
    # This node show diagnostic information in the frame image. It can
    # be used for debugging or monitoring system resource status.
    dict(
        type='MonitorNode',
        name='monitor',
        enable_key='m',
        enable=False,
        input_buffer='vis_notice',
        output_buffer='display'),
    # 'RecorderNode':
    # This node save the output video into a file.
    dict(
        type='RecorderNode',
        name='recorder',
        out_video_file='webcam_api_demo.mp4',
        input_buffer='display',
        output_buffer='_display_'
        # `_display_` is an executor-reserved buffer
    )
])

Reproduces the problem - command or script

python demo/webcam_api_demo.py

Reproduces the problem - error message

I want to add key point detection of hand on the basis of posture detection, but it still cannot detect key point of hand after adding it into human_pose.py according to the above method image

Additional information

No response

ChenZhenGui commented 1 year ago

I have set the default value of cuda to True. Why do I still call the cpu when running demo image

Tau-J commented 1 year ago

webcam_api_demo is going to be deprecated soon, if you just want to use webcam to inference, I suggest directly using demo scripts such as topdown_demo_with_mmdet.py, by specifying --input webcam