pifpaf:用于人体姿态估计的复合场
openpifpaf的Python项目详细描述
打开pifpaf
We propose a new bottom-up method for multi-person 2D human pose estimation that is particularly well suited for urban mobility such as self-driving cars and delivery robots. The new method, PifPaf, uses a Part Intensity Field (PIF) to localize body parts and a Part Association Field (PAF) to associate body parts with each other to form full human poses. Our method outperforms previous methods at low resolution and in crowded, cluttered and occluded scenes thanks to (i) our new composite field PAF encoding fine-grained information and (ii) the choice of Laplace loss for regressions which incorporates a notion of uncertainty. Our architecture is based on a fully convolutional, single-shot, box-free design. We perform on par with the existing state-of-the-art bottom-up method on the standard COCO keypoint task and produce state-of-the-art results on a modified COCO keypoint task for the transportation domain.
@article{kreiss2019pifpaf,
title={PifPaf: Composite Fields for Human Pose Estimation},
author={Kreiss, Sven and Bertoni, Lorenzo and Alahi, Alexandre},
journal={CVPR, arXiv preprint arXiv:1903.06593},
year={2019}
}
演示
图像信用:“Learning to surf”由Fotologic提供,在CC-BY-2.0下获得许可。
创建时间:
python3 -m openpifpaf.predict --show docs/coco/000000081988.jpg
有关更多演示,请参见
openpifpafwebdemo项目和
openpifpaf.webcam
命令。
还有一个Google Colab demo。
安装
python 3是必需的。不支持Python2。
不要克隆此存储库
并确保当前目录中没有名为openpifpaf
的文件夹。
pip3 install openpifpaf
对于现场演示,我们建议尝试
openpifpafwebdemo项目。
或者,openpifpaf.webcam
也提供了一个现场演示。
它需要opencv。使用全局安装的
从虚拟环境中打开cv,使用
--system-site-packages
选项并验证是否可以执行import cv2
。
为了开发openpifpaf源代码本身,您需要克隆这个存储库,然后:
pip3 install numpy cython
pip3 install --editable '.[train,test]'
最后一个命令在当前目录中安装python包 (由点表示)具有培训和 测试。
接口
python3 -m openpifpaf.predict --help
python3 -m openpifpaf.webcam --help
python3 -m openpifpaf.train --help
python3 -m openpifpaf.eval_coco --help
python3 -m openpifpaf.logs --help
要尝试的命令示例:
# live demoMPLBACKEND=macosx python3 -m openpifpaf.webcam --scale 0.1 --source=0# single image python3 -m openpifpaf.predict my_image.jpg --show
预先培训的车型
使用GTX1080Ti获得的CoCo VAL集上0.9.0版的性能指标:
Backbone | AP | APᴹ | APᴸ | t_{total} [ms] | t_{dec} [ms] |
---|---|---|---|---|---|
shufflenetv2x1 | 50.2 | 47.0 | 55.4 | 56 | 44 |
shufflenetv2x2 | 58.5 | 55.2 | 63.6 | 60 | 41 |
resnet50 | 63.3 | 60.7 | 67.8 | 79 | 38 |
resnext50 | 63.8 | 61.1 | 68.1 | 93 | 33 |
resnet101 | 66.5 | 63.1 | 71.9 | 100 | 35 |
resnet152 | 67.8 | 64.4 | 73.3 | 122 | 30 |
预处理的模型文件在此共享
Google Drive
你可以放进outputs
文件夹。预先训练的模型是
自动下载时间
使用命令行选项--checkpoint backbonenameasintableabove
。
要可视化日志:
python3 -m openpifpaf.logs \ outputs/resnet50block5-pif-paf-edge401-190424-122009.pkl.log \ outputs/resnet101block5-pif-paf-edge401-190412-151013.pkl.log \ outputs/resnet152block5-pif-paf-edge401-190412-121848.pkl.log
列车
有关安装说明,请参见datasets。 以前的研究见studies.ipynb。
训练模型:
python3 -m openpifpaf.train \ --lr=1e-3 \ --momentum=0.95 \ --epochs=75\ --lr-decay 6070\ --batch-size=8\ --basenet=resnet50block5 \ --head-quad=1\ --headnets pif paf \ --square-edge=401\ --regression-loss=laplace \ --lambdas 30225033\ --freeze-base=1
可以用^ {CD14>}选项精化现有模型。
要在每个纪元生成计算,请检查目录中的新 每5分钟快照一次:
while true; do \
CUDA_VISIBLE_DEVICES=0 find outputs/ -name "resnet101block5-pif-paf-l1-190109-113346.pkl.epoch???" -exec \
python3 -m openpifpaf.eval_coco --checkpoint {} -n 500 --long-edge=641 --skip-existing \; \
; \
sleep 300; \
done
人体骨骼
可可树/运动树/密度:
用python3 -m openpifpaf.data
创建。
视频
使用ffmpeg从video.avi
到video.pose.mp4
逐帧处理视频:
exportVIDEO=video.avi # change to your video file mkdir ${VIDEO}.images ffmpeg -i ${VIDEO} -qscale:v 2 -vf scale=641:-1 -f image2 ${VIDEO}.images/%05d.jpg python3 -m openpifpaf.predict --checkpoint resnet152 ${VIDEO}.images/*.jpg ffmpeg -framerate 24 -pattern_type glob -i ${VIDEO}.images/'*.jpg.skeleton.png' -vf scale=640:-1 -c:v libx264 -pix_fmt yuv420p ${VIDEO}.pose.mp4
在此过程中,ffmpeg将视频缩放到可以调整的641px
。