open-mmlab / mmpose

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

webcam_demo.py[Bug] #2373

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

here is my pose_estimation.py :

Copyright (c) OpenMMLab. All rights reserved.

executor_cfg = dict(

Basic configurations of the executor

name='Pose Estimation',
camera_id='D:/pythonProject/mmpose/50waystofall.mp4',
# 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='D://pythonProject//mmpose//demo//mmdetection_cfg//'
        'ssdlite_mobilenetv2-scratch_8xb24-600e_coco.py',
        model_checkpoint='https://download.openmmlab.com'
        '/mmdetection/v2.0/ssd/'
        'ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_'
        'scratch_600e_coco_20210629_110627-974d9307.pth',
        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:/pythonProject/mmpose/configs/body_2d_keypoint/topdown_heatmap/coco/mobilevit_coco-256x192.py',
        model_checkpoint="D:/pythonProject/mmpose/work_dirs/AP_epoch_300.pth",
        labels=['person'],
        input_buffer='det_result',
        output_buffer='human_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='human_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'),
    # 'SunglassesNode':
    # This node draw the sunglasses effect in the frame image.
    # Pose results is needed.
    dict(
        type='SunglassesEffectNode',
        name='sunglasses',
        enable_key='s',
        enable=False,
        input_buffer='vis',
        output_buffer='vis_sunglasses'),
    # # 'BigeyeEffectNode':
    # # This node draw the big-eye effetc in the frame image.
    # # Pose results is needed.
    dict(
        type='BigeyeEffectNode',
        name='big-eye',
        enable_key='b',
        enable=False,
        input_buffer='vis_sunglasses',
        output_buffer='vis_bigeye'),
    # '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_bigeye',
        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',
            '"s": Sunglasses effect B-)', '"b": Big-eye effect 0_0',
            '"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_demo.mp4',
        input_buffer='display',
        output_buffer='_display_'
        # `_display_` is an executor-reserved buffer
    )
])

Reproduces the problem - command or script

python webcam_demo.py

Reproduces the problem - error message

Loads checkpoint by http backend from path: https://download.openmmlab.com/mmdetection/v2.0/ssd/ssdlite_mobilenetv2_scratch_600e_coco/ssdlite_mobilenetv2_scratch_600e_coco_20210629_110627-974d9307.pth 05/18 11:58:50 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "node" registry tree. As a workaround, the current "node" registry in "mmpose" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized. Loads checkpoint by local backend from path: D:/pythonProject/mmpose/work_dirs/AP_epoch_300.pth 05/18 11:58:50 - mmengine - WARNING - Visualizer backend is not initialized because save_dir is None. D:\pythonProject\ViTPose\venv\lib\site-packages\mmdet\utils\setup_env.py:111: UserWarning: The current default scope "mmpose" is not "mmdet", register_all_modules will force the currentdefault scope to be "mmdet". If this is not expected, please set init_default_scope=False. warnings.warn('The current default scope ' D:\pythonProject\ViTPose\venv\lib\site-packages\numpy\core\fromnumeric.py:3464: RuntimeWarning: Mean of empty slice. return _methods._mean(a, axis=axis, dtype=dtype, D:\pythonProject\ViTPose\venv\lib\site-packages\numpy\core_methods.py:192: RuntimeWarning: invalid value encountered in scalar divide ret = ret.dtype.type(ret / rcount) Exception in thread detector: Traceback (most recent call last): File "D:\python-3.9.0\lib\threading.py", line 954, in _bootstrap_inner self.run() File "D:\pythonProject\mmpose\mmpose\apis\webcam\nodes\node.py", line 396, in run output_msg = self.process(input_msgs) File "D:\pythonProject\mmpose\mmpose\apis\webcam\nodes\model_nodes\detector_node.py", line 115, in process objects = self._post_process(preds) File "D:\pythonProject\mmpose\mmpose\apis\webcam\nodes\model_nodes\detector_node.py", line 127, in _post_process classes = self.model.dataset_meta['CLASSES'] KeyError: 'CLASSES'

Additional information

No response

Ben-Louis commented 1 year ago

Updating the MMPose to the latest version should resolve this issue

ChenZhenGui commented 1 year ago

here is my MMPoset version : Requirement already satisfied: mmpose in d:\pythonproject\mmpose (1.0.0rc0) Isn't this the latest?

Ben-Louis commented 1 year ago

Nope, the latest version is v1.0.0

ChenZhenGui commented 1 year ago

Ok, how should I update to the latest version? Will I delete my backbone if I pip uninstall first

ChenZhenGui commented 1 year ago

image

also have the problem

Tau-J commented 1 year ago

webcam_demo.py has been deprecated in v1.1.0. We suggest trying demo scripts to inference with webcam.