MMPose installation record

参考:GitHub - open-mmlab/mmpose: OpenMMLab Pose Estimation Toolbox and Benchmark.

1. Depending on the environment

        MMPose is available for Linux, Windows, and macOS. It requires Python 3.7+, CUDA 9.2+ and PyTorch 1.6+. My environment:

Windows 11

Python 3.9

CUDA 11.6

PyTorch 1.13

        Considering that my base environment has been configured with cuda, create a virtual environment that clones the base environment.

1. Create a conda virtual environment and activate it.

conda create --name mmpose--clone base
conda activate mmpose

2. Install MMEngine and MMCV using MIM

pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0"

3. Install MMdet

        Some of the inference example scripts in MMPose require human detection using MMDetection(mmdet). If you want to run these example scripts, you can install mmdet by running: (recommended)

mim install "mmdet>=3.0.0"

2. Install MMPose from source code

        Official document: If you develop your own tasks based on the MMPose framework, you need to add new functions, such as new models or data sets, or use various tools we provide. If you just want to call the interface of MMPose, or import the modules in MMPose in your own project. Just use mim to install it. That is, follow the following command to install it.

mim install "mmpose>=1.0.0"

        Install mmpose from source as follows:

cd E:\pythonproject\
git clone https://github.com/open-mmlab/mmpose.git
cd mmpose
pip install -r requirements.txt
pip install -v -e .
# "-v" 表示输出更多安装相关的信息
# "-e" 表示以可编辑形式安装,这样可以在不重新安装的情况下,让本地修改直接生效

        My MMPose path is as follows: 

         Note: For the problem of slow installation, it is recommended to go online scientifically.

3. Verify the installation

1. Verify that the installation packages are available

# 检查 Pytorch
import torch, torchvision
print('Pytorch 版本', torch.__version__)
print('torchvision版本', torchvision.__version__)
print('CUDA 是否可用',torch.cuda.is_available())

# 检查 mmcv
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print('CUDA版本', get_compiling_cuda_version())
print('编译器版本', get_compiler_version())

# 检查 mmpose
import mmpose
print('mmpose版本', mmpose.__version__)
Pytorch 版本 1.13.1+cu116
torchvision版本 0.14.1+cu116
CUDA 是否可用 True
CUDA版本 11.6
编译器版本 MSVC 192829924
mmpose版本 1.0.0

2. Whether the demo test is available

(1) You need to download configuration files and model weight files

mim download mmpose --config td-hm_hrnet-w48_8xb32-210e_coco-256x192  --dest .

        After completion, you will find these two files in the current directory: td-hm_hrnet-w48_8xb32-210e_coco-256x192.py and  td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth, are the configuration file and the corresponding model weight file respectively.

  (2) Example of verification reasoning

python demo/image_demo.py \
    tests/data/coco/000000000785.jpg \
    td-hm_hrnet-w48_8xb32-210e_coco-256x192.py \
    hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \
    --out-file vis_results.jpg \
    --draw-heatmap

        After running the above command, the code will draw the predicted key points and heatmap on the human body in the image, and save it to the current folder  vis_results.jpg中.

# 测试手部关键点
python demo/topdown_demo_with_mmdet.py \
    demo/mmdetection_cfg/cascade_rcnn_x101_64x4d_fpn_1class.py  \
    https://download.openmmlab.com/mmpose/mmdet_pretrained/cascade_rcnn_x101_64x4d_fpn_20e_onehand10k-dac19597_20201030.pth \
    configs/hand_2d_keypoint/topdown_heatmap/onehand10k/td-hm_hrnetv2-w18_8xb64-210e_onehand10k-256x256.py \
    https://download.openmmlab.com/mmpose/hand/hrnetv2/hrnetv2_w18_onehand10k_256x256-30bc9c6b_20210330.pth \
    --input tests/data/onehand10k/1402.jpg \
    --output-root vis_results \
    --draw-heatmap

4. Problem record

1、ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

        Update numpy to the latest version.

pip install --upgrade numpy

2、cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1255: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvNamedWindow'

        It may be that opencv is not configured well, but it does not affect the use of MMPose. Just remove --show when running the demo.

Guess you like

Origin blog.csdn.net/weixin_44855366/article/details/131221241