复现mmpose遇到的一些问题

1.安装,跟着官方检测一步一步来,我这波是在windows下安装。

概述 — MMPose 1.2.0 文档

这边要注意一下,装pytorch的时候最好用根据自己的cuda版本(nvidia-smi和nvcc-V),去官网上下。

Previous PyTorch Versions | PyTorch

要注意了,如果有GPU的道友一定要看准带下面这样的:

pytorch-cuda

 装完之后测试一下

>python
>import torch
>print(torch.cuda.is_available())

然后装mmcv与cuda,pytorch版本匹配要求,否则容易报下面这种错误

RuntimeError: nms_impl: implementation for device cuda:0 not found.

解决方法参考这个mmcv与cuda,pytorch版本匹配要求_mmcv对应版本-CSDN博客

2.用命令框去运行

本人课题的一个方面就是做3D关节检测的,所以这么用了推理器的运行。

(1)这边要注意的是pose3d hunman3d 是否要带单引号的问题

python demo/inferencer_demo.py tests/test_my/2.mp4 --pose3d human3d --pred-out-dir 'predictions' --vis-out-dir 'predictions'

官方给的别名是没有带单引号的。 

复现mmpose遇到的一些问题_第1张图片

复现mmpose遇到的一些问题_第2张图片

但是命令栏里面是带了单引号的,这边我比较困惑,我师兄带单引号能运行我不行,这边可能因人而异,或者我漏了装什么

python demo/inferencer_demo.py 'tests/data/coco/000000000785.jpg' \
    --pose2d 'human' --show --pred-out-dir 'predictions'

(2)在推断的时候报了关于OpenMP的一个错误

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

解决方法:设置环境变量

如错误信息中所示,你可以尝试设置环境变量 KMP_DUPLICATE_LIB_OKTRUE。这是一种不安全、不受支持、未记录的解决方法,因此请在使用之前谨慎考虑,并注意它可能引起的问题。

在 Linux 或 macOS 上,可以使用以下命令:

export KMP_DUPLICATE_LIB_OK=TRUE

在 Windows 上,可以使用:

set KMP_DUPLICATE_LIB_OK=TRUE

(3)和路径有关的错误

Traceback (most recent call last):
  File "demo/inferencer_demo.py", line 193, in 
    main()
  File "demo/inferencer_demo.py", line 188, in main
    for _ in inferencer(**call_args):
  File "...\mmpose\mmpose\apis\inferencers\mmpose_inferencer.py", line 191, in __call__
    inputs = self.inferencer._inputs_to_list(inputs)
  File "...\mmpose\mmpose\apis\inferencers\base_mmpose_inferencer.py", line 172, in _inputs_to_list
    input_type = mimetypes.guess_type(inputs)[0].split('/')[0]
AttributeError: 'NoneType' object has no attribute 'split'

这个错误表明在 mmpose_inferencer.py 脚本的 _inputs_to_list 方法中,mimetypes.guess_type(inputs) 返回了 None,导致后续代码尝试对 None 调用 split 方法时发生了 AttributeError

解决方法是保 mimetypes.guess_type(inputs) 返回的不是 None。这可能是因为输入的 inputs 不是一个合法的文件路径,或者在某些情况下,mimetypes 无法正确猜测文件类型。

具体做法是

python demo/inferencer_demo.py -h

#得到

usage: inferencer_demo.py [-h] [--pose2d POSE2D] [--pose2d-weights POSE2D_WEIGHTS] [--pose3d POSE3D] [--pose3d-weights POSE3D_WEIGHTS]
                          [--det-model DET_MODEL] [--det-weights DET_WEIGHTS] [--det-cat-ids DET_CAT_IDS [DET_CAT_IDS ...]] [--scope SCOPE]
                          [--device DEVICE] [--show] [--draw-bbox] [--draw-heatmap] [--bbox-thr BBOX_THR] [--nms-thr NMS_THR]
                          [--kpt-thr KPT_THR] [--tracking-thr TRACKING_THR] [--use-oks-tracking] [--disable-norm-pose-2d]
                          [--disable-rebase-keypoint] [--num-instances NUM_INSTANCES] [--radius RADIUS] [--thickness THICKNESS]
                          [--skeleton-style {mmpose,openpose}] [--black-background] [--vis-out-dir VIS_OUT_DIR] [--pred-out-dir PRED_OUT_DIR]
                          [--show-alias]
                          [inputs]
 

发现[inputs]就是一个裸地址,我起初以为要加个单引号修饰一下地址的,结果发现这个' tests/test_my/2.mp4 '反而影响到了输出格式。

最终运行结果

复现mmpose遇到的一些问题_第3张图片

感悟:在学习工具包的时候,安装的时候一定要认准官方的,但是也不能所有都按着官方装,因为它有时候只给个大概,然后是面对不同demo文件要去看看结合官方文档,以及函数自带-h去看看咋用。

你可能感兴趣的:(计算机视觉,python,机器学习)