MMPose 实践笔记

1. 配置环境

参考:https://mmpose.readthedocs.io/zh_CN/latest/install.html

第 1 步 使用 MIM 安装 MMCV

pip install -U openmim -i https://pypi.tuna.tsinghua.edu.cn/simple
mim install mmcv-full

第 2 步 安装 MMPose

我选择 从源码安装

git clone https://github.com/open-mmlab/mmpose.git
# 你懂的  容易失败  我参考了这个:https://blog.csdn.net/good_good_xiu/article/details/118567249
cd mmpose
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 又卡住了  失败的话  多试几次就好了
pip install -v -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
# "-v" 表示输出更多安装相关的信息
# "-e" 表示以可编辑形式安装,这样可以在不重新安装的情况下,让本地修改直接生效

2. 验证安装

从源码安装的 mmpose,那么直接运行以下命令进行验证:

第 1 步 我们需要下载配置文件和模型权重文件

mim download mmpose --config associative_embedding_hrnet_w32_coco_512x512  --dest .

在当前目录下找到这两个文件:associative_embedding_hrnet_w32_coco_512x512.py, hrnet_w32_coco_512x512-bcb8c247_20200816.pth, 分别是配置文件和对应的模型权重文件。

第 2 步 验证推理示例

如果您是从源码安装的 mmpose,那么直接运行以下命令进行验证:

python demo/bottom_up_img_demo.py associative_embedding_hrnet_w32_coco_512x512.py hrnet_w32_coco_512x512-bcb8c247_20200816.pth --img-path tests/data/coco/ --out-img-root vis_results

可以在 vis_results 这个目录下看到输出的图片,这些图片展示了人体姿态估计的结果。如:

image

创建 tests/data/custom 文件夹,内放一张图像 lxl.jpg,我们看看推理的结果:

python demo/bottom_up_img_demo.py associative_embedding_hrnet_w32_coco_512x512.py hrnet_w32_coco_512x512-bcb8c247_20200816.pth --img-path tests/data/custom/lxl.jpg  --out-img-root vis_results

image

好吧,好像有个点没识别出来。我的图像分辨率是 299*187 可能是分辨率太低或者模型不太行?

3. 使用预训练模型进行推理

运行演示

使用人工标注的人体框作为输入。

python demo/top_down_img_demo.py \
	configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/coco/hrnet_w48_coco_256x192.py \
	https://download.openmmlab.com/mmpose/top_down/hrnet/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \
	--img-root tests/data/coco/ --json-file tests/data/coco/test_coco.json \
	--out-img-root vis_results

image

2D Hand Keypoint Demo

https://gitee.com/open-mmlab/mmpose/blob/master/demo/docs/2d_hand_demo.md#2d-hand-keypoint-demo

使用 标注的框 来进行 2D Hand Keypoint。

python demo/top_down_img_demo.py \
	configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/onehand10k/res50_onehand10k_256x256.py \
	https://download.openmmlab.com/mmpose/top_down/resnet/res50_onehand10k_256x256-e67998f6_20200813.pth \
	--img-root tests/data/onehand10k/ --json-file tests/data/onehand10k/test_onehand10k.json \
	--out-img-root vis_results

image

这张图的手 回归的不太好。看来2D 的对于遮挡的不太行。

此外,可以使用一个模型来检测手的 bbox, 然后在使用 模型回归 手的关键点。而这个需要 安装 MMdet

python demo/top_down_img_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_kpt_sview_rgb_img/topdown_heatmap/onehand10k/res50_onehand10k_256x256.py \
	https://download.openmmlab.com/mmpose/top_down/resnet/res50_onehand10k_256x256-e67998f6_20200813.pth \
	--img-root tests/data/onehand10k/ \
	--img 9.jpg \
	--out-img-root vis_results

可能我之前安过 MMdet, 我直接运行成功了。

image

试试别的图:

image

显然,误识别了一个 hand bbox,还有就是画图时候点太大了。右手的 bbox 模型也没有检测出来。

安装 MMdet

如果需要安装,可参考:

https://github.com/open-mmlab/mmdetection/blob/master/docs/zh_cn/get_started.md

posted @ 2022-12-08 17:58  cold_moon  阅读(510)  评论(0编辑  收藏  举报