库名称:transformers
许可证:apache-2.0
支持语言:
VitPose模型卡片

ViTPose系列:面向人体姿态估计的简易视觉Transformer基线模型(ViTPose)与通用人体姿态估计基础模型(ViTPose+)。该模型在MS COCO关键点测试集上达到81.1 AP的精度。
模型详情
尽管设计时未融入特定领域知识,朴素视觉Transformer已在视觉识别任务中展现出卓越性能。然而,这类简单结构在姿态估计任务中的潜力尚未充分挖掘。本文通过名为ViTPose的基线模型,从模型结构简洁性、规模可扩展性、训练范式灵活性以及模型间知识迁移性等维度,系统揭示了朴素视觉Transformer在姿态估计中的惊人潜力。具体而言,ViTPose采用非层级式视觉Transformer作为骨干网络提取人体实例特征,配合轻量级解码器进行姿态估计。得益于Transformer的可扩展模型容量与高并行性,其参数量可从1亿灵活扩展至10亿,在吞吐量与性能之间建立新的帕累托前沿。此外,该模型在注意力类型、输入分辨率、预训练/微调策略以及多任务处理方面均展现出显著灵活性。我们通过实验证明,大型ViTPose模型的知识可通过简单的知识令牌有效迁移至小型模型。实验结果显示,基础版ViTPose已在MS COCO关键点检测基准测试中超越代表性方法,而最大模型更以80.9 AP的成绩创下新纪录。代码与模型详见:https://github.com/ViTAE-Transformer/ViTPose
模型描述
本卡片为托管于HuggingFace Hub的transformers模型自动生成。
- 开发团队:徐宇飞、张静、张启明、陶大程
- 资助方:ARC FL-170100117与IH-180100002
- 许可证:Apache-2.0
- 移植至🤗 Transformers:Sangbum Choi与Niels Rogge
模型来源
- 原始仓库:https://github.com/ViTAE-Transformer/ViTPose
- 论文:https://arxiv.org/pdf/2204.12484
- 演示:https://huggingface.co/spaces?sort=trending&search=vitpose
应用场景
ViTPose模型由ViTAE-Transformer团队开发,主要应用于姿态估计任务:
- 人体姿态估计:检测图像/视频中人体关键点(如头、肩、肘、腕、髋、膝、踝等)
- 动作识别:通过时序姿态分析识别人体行为
- 安防监控:分析公共场所的人类行为
- 健康健身:健身应用中的动作追踪与姿势矫正
- 游戏动画:生成逼真角色动作
偏差、风险与局限
尽管ViTPose在MS COCO数据集上达到SOTA性能,其潜力仍可通过复杂解码器或FPN结构等先进技术进一步挖掘。虽然模型展现出简洁性、可扩展性、灵活性和迁移性等优势,但提示调优等技术的探索仍有空间。未来工作可拓展至动物姿态估计、面部关键点检测等场景。
快速开始
import torch
import requests
import numpy as np
from PIL import Image
from transformers import (
AutoProcessor,
RTDetrForObjectDetection,
VitPoseForPoseEstimation,
)
device = "cuda" if torch.cuda.is_available() else "cpu"
url = "http://images.cocodataset.org/val2017/000000000139.jpg"
image = Image.open(requests.get(url, stream=True).raw)
person_image_processor = AutoProcessor.from_pretrained("PekingU/rtdetr_r50vd_coco_o365")
person_model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd_coco_o365", device_map=device)
inputs = person_image_processor(images=image, return_tensors="pt").to(device)
with torch.no_grad():
outputs = person_model(**inputs)
results = person_image_processor.post_process_object_detection(outputs, target_sizes=torch.tensor([(image.height, image.width)]), threshold=0.3)
person_boxes = results[0]["boxes"][results[0]["labels"] == 0].cpu().numpy()
person_boxes[:, 2] -= person_boxes[:, 0]
person_boxes[:, 3] -= person_boxes[:, 1]
image_processor = AutoProcessor.from_pretrained("usyd-community/vitpose-base-simple")
model = VitPoseForPoseEstimation.from_pretrained("usyd-community/vitpose-base-simple", device_map=device)
inputs = image_processor(image, boxes=[person_boxes], return_tensors="pt").to(device)
with torch.no_grad():
outputs = model(**inputs)
pose_results = image_processor.post_process_pose_estimation(outputs, boxes=[person_boxes], threshold=0.3)
for i, person_pose in enumerate(pose_results[0]):
print(f"人物#{i}")
for keypoint, label, score in zip(person_pose["keypoints"], person_pose["labels"], person_pose["scores"]):
print(f" - {model.config.id2label[label.item()]}: x={keypoint[0].item():.2f}, y={keypoint[1].item():.2f}, 置信度={score.item():.2f}")
训练详情
训练数据
使用MS COCO(CC-BY-4.0许可)、AI Challenger、MPII(BSD许可)和CrowdPose数据集进行训练,OCHuman数据集仅用于遮挡场景评估。各数据集包含11.8万-20万张训练图像,标注14-17个关键点。
超参数配置

性能指标

评估
在OCHuman验证/测试集(重度遮挡场景)和MPII验证集(PCKh指标)上评估性能,均使用真实边界框以避免检测器干扰。
结果

模型架构

硬件环境
基于mmpose框架,使用8块A100 GPU进行训练
引用
@article{xu2022vitposesimplevisiontransformer,
title={ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation},
author={Yufei Xu and Jing Zhang and Qiming Zhang and Dacheng Tao},
year={2022},
eprint={2204.12484},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2204.12484}
}