关于mmpose进行手姿势别出现'scn' is 12的bug

python在mmpose的3d手姿势别识别过程中遇到一个bug,大概是说opencv输入的图像灰度的问题,尝试了多种方法仍报错,本人mac电脑,同样的代码在另一台电脑的linux系统可以运行,具体报错情况完整代码如下,希望可以帮忙解决这个bug,非常感谢:


(openmmlab) cedar@liuxuesongdeMacBook-Air mmpose % python demo/interhand3d_img_demo.py \
    configs/hand/3d_kpt_sview_rgb_img/internet/interhand3d/res50_interhand3d_all_256x256.py \
    https://download.openmmlab.com/mmpose/hand3d/internet/res50_intehand3d_all_256x256-b9c1cf4c_20210506.pth \
    --json-file tests/data/interhand2.6m/test_interhand2.6m_data.json \
    --img-root tests/data/interhand2.6m \
    --camera-param-file tests/data/interhand2.6m/test_interhand2.6m_camera.json \
    --gt-joints-file tests/data/interhand2.6m/test_interhand2.6m_joint_3d.json \ 
    --out-img-root vis_results \
    --rebase-keypoint-height \
    --show-ground-truth --device=cpu  
/Users/cedar/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmcv/__init__.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
  warnings.warn(
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
load checkpoint from http path: https://download.openmmlab.com/mmpose/hand3d/internet/res50_intehand3d_all_256x256-b9c1cf4c_20210506.pth
[                                                  ] 0/4, elapsed: 0s, ETA:/Users/cedar/mmpose/mmpose/datasets/pipelines/top_down_transform.py:39: UserWarning: Use the "center" and "scale" that already exist in the data sample. The padding will still be applied.
  warnings.warn(
Traceback (most recent call last):
  File "/Users/cedar/mmpose/demo/interhand3d_img_demo.py", line 259, in 
    main()
  File "/Users/cedar/mmpose/demo/interhand3d_img_demo.py", line 244, in main
    vis_3d_pose_result(
  File "/Users/cedar/mmpose/mmpose/apis/inference_3d.py", line 463, in vis_3d_pose_result
    img = model.show_result(
  File "/Users/cedar/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmcv/utils/misc.py", line 340, in new_func
    output = old_func(*args, **kwargs)
  File "/Users/cedar/mmpose/mmpose/models/detectors/interhand_3d.py", line 210, in show_result
    img_vis = imshow_keypoints_3d(
  File "/Users/cedar/mmpose/mmpose/core/visualization/image.py", line 354, in imshow_keypoints_3d
    img_vis = mmcv.rgb2bgr(img_vis)
  File "/Users/cedar/opt/anaconda3/envs/openmmlab/lib/python3.9/site-packages/mmcv/image/colorspace.py", line 282, in convert_color
    out_img = cv2.cvtColor(img, code)
cv2.error: OpenCV(4.6.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::(anonymous namespace)::CvtHelper, cv::impl::(anonymous namespace)::Set<3, 4, -1>, cv::impl::(anonymous namespace)::Set<0, 2, 5>, cv::impl::(anonymous namespace)::NONE>::CvtHelper(cv::InputArray, cv::OutputArray, int) [VScn = cv::impl::(anonymous namespace)::Set<3, 4, -1>, VDcn = cv::impl::(anonymous namespace)::Set<3, 4, -1>, VDepth = cv::impl::(anonymous namespace)::Set<0, 2, 5>, sizePolicy = cv::impl::(anonymous namespace)::NONE]'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 12

ChatGPT尝试为您解答,仅供参考
看起来您在使用mmpose库时遇到了一个问题,报错信息中提到了opencv,因此可能是opencv处理图像时出现了问题。


首先,您可以尝试在调用opencv函数之前打印出输入的图像数据,以查看输入的图像是否为灰度图像。如果输入的图像不是灰度图像,您可以使用opencv的cv2.cvtColor()函数将其转换为灰度图像。


您也可以查看opencv文档,了解更多有关图像处理的知识。


另外,您可以尝试在不同的环境中运行这个代码,以确定是否存在环境差异导致的问题。例如,您可以尝试在Mac OS和Linux之间进行比较。


如果您仍然无法解决这个问题,您可以尝试在mmpose的GitHub页面上提交一个issue,并向开发人员询问帮助。或者,您也可以在Stack Overflow等社区中寻求帮助。