1、创建虚拟环境
conda create --name openmmlab python=3.8 -y
2、进入虚拟环境
conda activate openmmlab
3、安装ROG笔记本的torch
pip install "d:\ChromeDownloads\torch-2.0.1+cu118-cp38-cp38-win_amd64.whl"
4、安装ROG笔记本的torchvision和torchaudio
pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 -f https://download.pytorch.org/whl/torch_stable.html
5、到python里验证一下torch、torchvision和torchaudio安装是否成功
import torch
print(torch.__version__)
显示:2.0.1+cu118
import torchvision
print(torch.cuda.is_available())
显示:True
6、用 MIM 安装 MMEngine、MMCV和mmdet
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.1"
mim install "mmdet>=3.1.0"
7、到python里验证一下mmengine、mmcv、mmdet安装是否成功
import mmcv
print(mmcv.__version__)
显示:2.1.0
from mmcv.ops import get_compiling_cuda_version, get_compiler_version
print(get_compiling_cuda_version())
显示:CUDA版本 11.8
print(get_compiler_version())
显示:编译器版本 MSVC 192930148
import mmdet
print('mmdetection版本', mmdet.__version__)
显示:mmdetection版本 3.3.0
8、从源码安装MMPose
git clone https://github.com/open-mmlab/mmpose.git
cd mmpose
pip install -r requirements.txt
pip install -v -e .
9、到python里验证一下MMPose安装是否成功
import mmpose
print('mmpose版本', mmpose.__version__)
显示:mmpose版本 1.3.1
10、下载配置文件和模型权重文件
mim download mmpose --config td-hm_hrnet-w48_8xb32-210e_coco-256x192 --dest .
完成之后,会在当前目录下找到这两个文件:
td-hm_hrnet-w48_8xb32-210e_coco-256x192.py
td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth
分别是配置文件和对应的模型权重文件
11、执行命令验证一下关键点较少的模型
识别图片
python demo/image_demo.py C:/Users/13466/mmpose/QY_Test/01.jpg td-hm_hrnet-w48_8xb32-210e_coco-256x192.py td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth --out-file C:/Users/13466/mmpose/QY_Test/vis_results_01.jpg --draw-heatmap
python demo/image_demo.py
C:/Users/13466/mmpose/QY_Test/02.jpg
td-hm_hrnet-w48_8xb32-210e_coco-256x192.py
td-hm_hrnet-w48_8xb32-210e_coco-256x192-0e67c616_20220913.pth
--out-file C:/Users/13466/mmpose/QY_Test/vis_results_02.jpg
--draw-heatmap
识别摄像头
python demo/topdown_demo_with_mmdet.py projects/rtmpose/rtmdet/person/rtmdet_nano_320-8xb32_coco-person.py https://download.openmmlab.com/mmpose/v1/projects/rtmpose/rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth projects/rtmpose/rtmpose/body_2d_keypoint/rtmpose-m_8xb256-420e_coco-256x192.py https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-aic-coco_pt-aic-coco_420e-256x192-63eb25f7_20230126.pth --input webcam --show
12、执行命令验证一下关键点较多的模型
识别目录
python demo/inferencer_demo.py C:/Users/13466/mmpose/QY_Test --pose2d wholebody --vis-out-dir C:/Users/13466/mmpose/QY_Result
识别摄像头
python demo/inferencer_demo.py webcam --pose2d wholebody --draw-heatmap