ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

ViTPose 仓库实战:基于 SimpleBaseline2D + ResNet 的 Animal-Pose 动物姿态估计配置全解

ViTPose 仓库实战:基于 SimpleBaseline2D + ResNet 的 Animal-Pose 动物姿态估计配置全解 人工智能计算机视觉深度学习【免费下载链接】ViTPoseThe official repo for [NeurIPS22] ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation and [TPAMI23] ViTPose: Vision Transformer for Generic Body Pose Estimation项目地址https://gitcode.com/gh_mirrors/vi/ViTPose点击查看免费下载本文以 ViTPose 仓库中configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/resnet_animalpose.md为骨架结合其配套的 ResNet-50/101/152 三套训练配置与mmpose源码完整讲解如何在 Animal-Pose 动物关键点数据集上完成自顶向下Top-Down热力图式姿态估计的训练、评测与推理。读完本文你将掌握SimpleBaseline2D 的模型结构、20 个动物关键点的通道配置、完整的可复现训练配置、验证集基准指标以及tools/train.py与tools/test.py的具体用法。一、背景与基准SimpleBaseline2D 与 Animal-Pose 数据集1.1 算法出处SimpleBaseline2D, ECCV 2018本配置对应的算法是 Bin Xiao 等人的Simple Baselines for Human Pose Estimation and TrackingECCV 2018即常说的SimpleBaseline2D一个仅由主干网络 若干反卷积层 1x1 卷积构成的最简姿态估计基线。原文档中给出了该算法的 BibTeX 引用inproceedings{xiao2018simple, title{Simple baselines for human pose estimation and tracking}, author{Xiao, Bin and Wu, Haiping and Wei, Yichen}, booktitle{Proceedings of the European conference on computer vision (ECCV)}, pages{466--481}, year{2018} }从源码看该简单基线在 ViTPose 仓库中的实现位于 mmpose/models/heads/topdown_heatmap_simple_head.pyTopdownHeatmapSimpleHead的类注释明确说明其由0 个反卷积层 一个简单 conv2d 层构成对应原始论文结构。仓库的model-index.yml汇总文件见 configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/resnet_animalpose.yml也将这三套配置统一收录在SimpleBaseline2D集合之下。1.2 数据集出处Animal-Pose, ICCV 2019实验使用的数据集是 Jinkun Cao 等人提出的Animal-PoseCross-Domain Adaptation for Animal Pose Estimation, ICCV 2019原文档附带的 BibTeX 引用如下InProceedings{Cao_2019_ICCV, author {Cao, Jinkun and Tang, Hongyang and Fang, Hao-Shu and Shen, Xiaoyong and Lu, Cewu and Tai, Yu-Wing}, title {Cross-Domain Adaptation for Animal Pose Estimation}, booktitle {The IEEE International Conference on Computer Vision (ICCV)}, month {October}, year {2019} }Animal-Pose 数据集的元信息定义在 configs/base/datasets/animalpose.py它定义了完整的20 个动物关键点头部/躯干左眼 L_Eye、右眼 R_Eye、左耳基 L_EarBase、右耳基 R_EarBase、鼻子 Nose、喉咙 Throat、尾根 TailBase、肩胛 Withers四肢左/右前肘 L_F_Elbow、R_F_Elbow左/右后肘 L_B_Elbow、R_B_Elbow左/右前膝 L_F_Knee、R_F_Knee左/右后膝 L_B_Knee、R_B_Knee以及左/右前爪 L_F_Paw、R_F_Paw、左/右后爪 L_B_Paw、R_B_Paw。同时该基配置还提供了关键点之间的skeleton_info骨骼连线定义、joint_weights各关键点损失权重后爪等部位权重更高以及从 COCO 的 pycocotools 推导的sigmas用于 OKS 计算这些正是后续评测指标计算所依赖的元数据。二、三套基准配置与验证集指标总览原文档给出了 AnimalPose 验证集共 1117 个实例上的完整结果表本文完整保留如下ArchInput SizeAPAP50AP75ARAR50ckptlogpose_resnet_50256x2560.6880.9450.7720.7330.952ckptlogpose_resnet_101256x2560.6960.9480.7850.7370.954ckptlogpose_resnet_152256x2560.7090.9480.7970.7490.951ckptlog关键结论依据原文档数据三套模型均以256x256图像输入热力图输出尺寸为64x64主干网络加深带来稳定增益AP 从 ResNet-50 的0.688提升到 ResNet-101 的0.696、ResNet-152 的0.709AP75也从 0.772 提升到 0.797更深的模型 AP50约 0.948与 AR50约 0.95基本持平说明粗粒度定位上限已接近饱和收益主要体现在精确定位AP75。配套的 resnet_animalpose.yml 在model-index集合中记录了同样的指标AP: 0.688/0.696/0.709以及对应权重文件的下载地址是自动化收集与展示这些基准的统一入口。三、训练配置逐段精讲以 ResNet-50 为例下面以 res50_animalpose_256x256.py 为模板逐段解读其完整配置ResNet-101/152 两套配置除pretrained与backbone.depth外完全一致。3.1 基配置继承_base_ [ ../../../../_base_/default_runtime.py, ../../../../_base_/datasets/animalpose.py ]configs/base/default_runtime.py提供训练运行时基础设定包括checkpoint_config每 10 个 epoch 存一次权重、log_config、dist_params后端nccl、workflow[(train, 1)]以及两项重要的性能设定——opencv_num_threads 0禁用 OpenCV 多线程避免系统过载与mp_start_method fork加速多进程训练。configs/base/datasets/animalpose.py提供上文介绍的dataset_info关键点、骨骼、权重、sigma。3.2 优化器与学习率策略evaluation dict(interval10, metricmAP, save_bestAP) optimizer dict(typeAdam, lr5e-4) optimizer_config dict(grad_clipNone) lr_config dict( policystep, warmuplinear, warmup_iters500, warmup_ratio0.001, step[170, 200]) total_epochs 210 log_config dict( interval1, hooks[ dict(typeTextLoggerHook), # dict(typeTensorboardLoggerHook) ])要点说明优化器采用Adam初始学习率5e-4且不做梯度裁剪grad_clipNone学习率采用step 衰减策略前 500 次迭代做线性 warmup初始为 0.001 倍 lr并在第170、200epoch 两处衰减总训练210 个 epoch评测每10个 epoch 在验证集上评测一次指标为mAP并按AP选择最佳权重保存日志每 1 个迭代输出一次文本日志TextLoggerHook如需 TensorBoard 可视化取消注释TensorboardLoggerHook即可。3.3 通道配置20 个关键点的映射channel_cfg dict( num_output_channels20, dataset_joints20, dataset_channel[ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], ], inference_channel[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ])Animal-Pose 的 20 个关键点与网络输出通道一一对应dataset_channel与inference_channel均为 0–19 的恒等映射因此num_output_channels、dataset_joints均为 20。该索引顺序必须与_base_/datasets/animalpose.py中keypoint_info的 id 严格对齐id 0–19 依次对应 L_Eye、R_Eye、…、R_B_Paw。3.4 模型结构定义model dict( typeTopDown, pretrainedtorchvision://resnet50, backbonedict(typeResNet, depth50), keypoint_headdict( typeTopdownHeatmapSimpleHead, in_channels2048, out_channelschannel_cfg[num_output_channels], loss_keypointdict(typeJointsMSELoss, use_target_weightTrue)), train_cfgdict(), test_cfgdict( flip_testTrue, post_processdefault, shift_heatmapTrue, modulate_kernel11))逐项剖析检测器类型TopDown自顶向下范式先由外部检测器给出动物框训练/验证时用 GT 框再对每个框内的动物做关键点回归主干ResNet从torchvision://resnet50加载 ImageNet 预训练权重depth50。在 mmpose/models/backbones/resnet.py 中arch_settings定义了各深度的结构ResNet-50 为Bottleneck (3, 4, 6, 3)ResNet-101 为(3, 4, 23, 3)ResNet-152 为(3, 8, 36, 3)。默认out_indices(3,)即取最后一个 stage 的特征图输出通道数为 2048关键点头TopdownHeatmapSimpleHead输入 ResNet 的 2048 通道特征输出 20 个通道的 64x64 热力图。从 topdown_heatmap_simple_head.py 可看到其默认构造3 层反卷积num_deconv_layers3、每层 256 个 filter、kernel 4、stride 2将特征图放大 8 倍再接 1x1 卷积输出out_channels个通道损失函数JointsMSELoss标准 MSE 热力图损失并开启use_target_weightTrue即利用target_weight对遮挡/不可见关键点进行加权对应数据集配置中的joint_weights测试配置flip_testTrue开启水平翻转测试融合shift_heatmapTrue对翻转热力图做像素平移补偿modulate_kernel11指定调制卷积核大小post_processdefault使用默认的后处理含坐标解算与偏移修正。3.5 数据配置与数据增强流水线data_cfg dict( image_size[256, 256], heatmap_size[64, 64], num_output_channelschannel_cfg[num_output_channels], num_jointschannel_cfg[dataset_joints], dataset_channelchannel_cfg[dataset_channel], inference_channelchannel_cfg[inference_channel], soft_nmsFalse, nms_thr1.0, oks_thr0.9, vis_thr0.2, use_gt_bboxTrue, det_bbox_thr0.0, bbox_file, )输入输出尺寸输入图像 256x256热力图 64x641/4 分辨率两者比例一致框与 NMSuse_gt_bboxTrue表示验证/测试直接使用数据集提供的 GT 检测框不依赖外部检测器soft_nmsFalse、nms_thr1.0表示不做关键点层面的 NMSoks_thr0.9、vis_thr0.2分别控制评测时 OKS 匹配阈值与可视化置信度阈值数据增强train_pipelineTopDownRandomFlip50% 概率水平翻转flip_prob0.5TopDownHalfBodyTransform以 0.3 概率仅保留包含 ≥8 个可见关键点的半身区域增加对遮挡的鲁棒性TopDownGetRandomScaleRotation旋转幅度 ±40°、尺度扰动 0.5TopDownAffine仿射变换裁剪到 256x256标准化使用 ImageNet 均值[0.485, 0.456, 0.406]与方差[0.229, 0.224, 0.225]TopDownGenerateTarget, sigma2以高斯核σ2生成 64x64 热力图目标Collect收集img/target/target_weight以及flip_pairs等元信息。验证/测试流水线val_pipeline / test_pipeline只做仿射变换与标准化不进行随机增强test_pipeline val_pipeline直接复用。3.6 数据路径与 DataLoader 配置data_root data/animalpose data dict( samples_per_gpu64, workers_per_gpu2, val_dataloaderdict(samples_per_gpu32), test_dataloaderdict(samples_per_gpu32), traindict( typeAnimalPoseDataset, ann_filef{data_root}/annotations/animalpose_train.json, img_prefixf{data_root}/, data_cfgdata_cfg, pipelinetrain_pipeline, dataset_info{{_base_.dataset_info}}), valdict( typeAnimalPoseDataset, ann_filef{data_root}/annotations/animalpose_val.json, img_prefixf{data_root}/, data_cfgdata_cfg, pipelineval_pipeline, dataset_info{{_base_.dataset_info}}), testdict( typeAnimalPoseDataset, ann_filef{data_root}/annotations/animalpose_val.json, img_prefixf{data_root}/, data_cfgdata_cfg, pipelinetest_pipeline, dataset_info{{_base_.dataset_info}}), )数据集类型为AnimalPoseDataset训练用animalpose_train.json验证与测试共用animalpose_val.json图像根目录为data/animalpose/训练时每 GPU 批大小64验证/测试时每 GPU 32、每个 GPU 2 个加载进程dataset_info{{_base_.dataset_info}}将基配置中的 20 点元信息注入数据集。四、训练、评测与推理实战命令4.1 训练单卡训练python tools/train.py configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/res50_animalpose_256x256.py --work-dir work_dirs/animalpose/res50多卡分布式训练假设 8 卡bash tools/dist_train.sh configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/res50_animalpose_256x256.py 8 --work-dir work_dirs/animalpose/res50训练入口 tools/train.py 会依次构建数据集与模型并按配置中的lr_config、evaluation等策略执行 210 个 epoch每 10 个 epoch 保存一次 checkpoint 并在验证集上评测 mAP按save_bestAP保留最优权重。4.2 评测使用训练好的权重在验证集上评估--eval mAP指定评测指标对应evaluation.metricmAPpython tools/test.py configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/res50_animalpose_256x256.py \ https://download.openmmlab.com/mmpose/animal/resnet/res50_animalpose_256x256-e1f30bff_20210426.pth \ --eval mAP可选参数依据 tools/test.py--out保存评测结果、--fuse-conv-bn融合 Conv 与 BN 以略微提升推理速度、--cfg-options覆盖配置。测试阶段mmpose/models/detectors/top_down.py 的forward_test会同时前向原图与水平翻转图经flip_back对齐翻转热力图并均值融合再经decode解算出 20 个关键点坐标与置信度。4.3 单图推理 DemoViTPose 仓库提供了现成的自顶向下单图推理脚本 demo/top_down_img_demo.py可基于上述权重直接对动物图片推理python demo/top_down_img_demo.py \ configs/animal/2d_kpt_sview_rgb_img/topdown_heatmap/animalpose/res50_animalpose_256x256.py \ https://download.openmmlab.com/mmpose/animal/resnet/res50_animalpose_256x256-e1f30bff_20210426.pth \ --img-root tests/data/animalpose/ \ --json-file tests/data/animalpose/test_animalpose.json \ --out-img-root vis_results其中--img-root与--json-file可指向仓库自带的测试样例图片见 tests/data/animalpose/输出可视化结果到vis_results/目录--show参数可实时显示。五、换用 ResNet-101 / ResNet-152 与进阶调参建议三套配置的唯一差异仅在模型段# res101 pretrainedtorchvision://resnet101 backbonedict(typeResNet, depth101) # res152 pretrainedtorchvision://resnet152 backbonedict(typeResNet, depth152)在 res101_animalpose_256x256.py 与 res152_animalpose_256x256.py 中其余训练策略、数据流水线与评估设置与 ResNet-50 完全相同因此在同类硬件上可横向对比主干深度对 AP 的影响。进阶调参建议基于源码语义需自行实验验证精度优先将flip_test保持开启默认True见 top_down.py并尝试增大modulate_kernel或改为post_processunbiased会引入 offset 细化通常可在 AP 上获得小幅提升训练加速若显存紧张可降低samples_per_gpu并相应提高total_epochs若希望从零训练将pretrained置为None热力图分辨率将heatmap_size由 64x64 提升到 128x128 并同步调大sigma可提升定位精度但训练/推理开销随之增加。六、总结ViTPose 仓库以 resnet_animalpose.md 为主线为 Animal-Pose 动物姿态估计提供了 SimpleBaseline2DResNet-50/101/152 20 点热力图回归的完整基准模型结构简单ResNet 主干 3 层反卷积 1x1 卷积、配置清晰可复现、三档深度的指标呈单调提升AP 0.688 → 0.696 → 0.709。无论是作为该数据集上的标准基线还是作为学习 Top-Down 热力图范式的最小可运行示例这套配置都极具参考价值——读者可以直接在仓库中训练、评测并接入 demo/top_down_img_demo.py 完成端到端推理。赞分享人工智能计算机视觉深度学习【免费下载链接】ViTPoseThe official repo for [NeurIPS22] ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation and [TPAMI23] ViTPose: Vision Transformer for Generic Body Pose Estimation项目地址https://gitcode.com/gh_mirrors/vi/ViTPose点击查看免费下载相关推荐mmpose 动物姿态估计实战SimpleBaseline2D Animal-Pose 数据集上的 ResNet 热图模型解析与训练指南mmpose 动物姿态估计实战SimpleBaseline2D Animal Pose 数据集上的 ResNet 热图模型解析与训练指南 本篇技术指南围绕计算机视觉人工智能深度学习MMPose 实战基于 SimpleBaseline2DResNet与 Top-Down Heatmap 的 AP-10K 动物姿态估计MMPose 实战基于 SimpleBaseline2DResNet与 Top Down Heatmap 的 AP 10K 动物姿态估计 本文以 MMPo计算机视觉人工智能深度学习MMPose sub-JHMDB 人体姿态估计实战SimpleBaseline2D ResNet-50 热力图方案的全解析与 PCK/tPCK 评估MMPose sub JHMDB 人体姿态估计实战SimpleBaseline2D ResNet 50 热力图方案的全解析与 PCK/tPCK 评估 本文计算机视觉人工智能深度学习上一篇Linux文件管理终极指南3种高效策略提升工作效率下一篇CuBERT 源码级解析用 BERT 学习源代码的上下文嵌入与微调实践创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表