估計上的配置解析與評測指南)
人工智能計算機視覺深度學習【免費下載鏈接】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點擊查看免費下載本文以 configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman/hrnet_ochuman.md 為核心系統(tǒng)講解 ViTPose 倉庫中 HRNet 系列模型在 OCHuman 數(shù)據(jù)集上的評測設(shè)定、四套官方配置的完整參數(shù)含義以及訓練/測試/評估的端到端實操方法。讀完本文你將掌握 top-down 姿態(tài)估計在嚴重遮擋場景下的交叉數(shù)據(jù)集評測流程并能對照 OCHuman 數(shù)據(jù)集基礎(chǔ)配置 與 HRNet 評測配置 自行復現(xiàn)與擴展實驗。OCHuman為遮擋魯棒性而生的評測基準OCHumanOccluded Human數(shù)據(jù)集出自 CVPR2019 論文Pose2Seg: Detection Free Human Instance Segmentation從源碼文檔 mmpose/datasets/datasets/top_down/topdown_ochuman_dataset.py 可知其規(guī)模與定位OCHuman dataset contains 8110 heavily occluded human instances within 4731 images. OCHuman dataset is designed for validation and testing. To evaluate on OCHuman, the model should be trained on COCO training set, and then test the robustness of the model to occlusion using OCHuman.即OCHuman 包含4731 張圖像、8110 個重度遮擋人體實例其設(shè)計目的就是僅用于驗證與測試專門考察模型在人體間相互遮擋、自遮擋等困難場景下的關(guān)鍵點回歸能力。因此倉庫中的全部 OCHuman 評測實驗都遵循同一個約定Following the common setting, the models are trained on COCO train dataset, and evaluate on OCHuman dataset.也就是在 COCO train2017 上訓練在 OCHuman 上直接評估的跨數(shù)據(jù)集評測范式用于檢驗模型對遮擋的泛化魯棒性。OCHuman 的關(guān)鍵點定義與 COCO 完全一致17 個關(guān)鍵點對應關(guān)系在 topdown_ochuman_dataset.py 中列明0: nose、1: left_eye、2: right_eye、3: left_ear、4: right_ear、5: left_shoulder、6: right_shoulder、7: left_elbow、8: right_elbow、9: left_wrist、10: right_wrist、11: left_hip、12: right_hip、13: left_knee、14: right_knee、15: left_ankle、16: right_ankle。正因為與 COCO 同構(gòu)模型無需改動輸出通道即可跨數(shù)據(jù)集評測。官方評測結(jié)果總覽GT 框設(shè)定原文檔給出的是ground-truth bounding boxesGT 框設(shè)定下的評測結(jié)果即測試時不使用外部檢測器直接用標注框裁剪人體區(qū)域。完整結(jié)果表繼承如下ArchInput SizeAPAP50AP75ARAR50pose_hrnet_w32256x1920.5910.7480.6410.6310.775pose_hrnet_w32384x2880.6060.7480.6500.6470.776pose_hrnet_w48256x1920.6110.7520.6630.6480.778pose_hrnet_w48384x2880.6160.7490.6630.6530.773對應的模型元數(shù)據(jù)、任務類型、指標與權(quán)重字段均登記在 hrnet_ochuman.yml 中每個模型均標注Training Data: OCHuman、Task: Body 2D KeypointWeights字段記錄了官方權(quán)重文件。從表中可以讀出兩點規(guī)律分辨率紅利同一骨干下384x288 輸入普遍優(yōu)于 256x192w32 的 AP 從 0.591 提升到 0.606w48 從 0.611 提升到 0.616說明遮擋場景下更精細的空間分辨率有助于關(guān)鍵點定位骨干容量紅利同一分辨率下w48 優(yōu)于 w32256x192 時 AP 0.611 vs 0.591384x288 時 0.616 vs 0.606更寬的高分辨率分支帶來更強的表征能力。配置文件逐段精讀以 hrnet_w32_ochuman_256x192.py 為例其余三份配置結(jié)構(gòu)一致僅分辨率、骨干寬度與部分超參不同逐段拆解其含義?;A(chǔ)繼承與評測策略_base_ [ ../../../../_base_/default_runtime.py, ../../../../_base_/datasets/ochuman.py ] evaluation dict(interval10, metricmAP, save_bestAP)default_runtime.py見 configs/base/default_runtime.py提供運行時基礎(chǔ)設(shè)定checkpoint_config dict(interval10)每 10 個 epoch 存一次 checkpointlog_config每 50 個 iter 輸出一次日志TextLoggerHook可切換 TensorboardLoggerHookdist_params dict(backendnccl)支持分布式訓練workflow [(train, 1)]為純訓練工作流還包含opencv_num_threads 0關(guān)閉 OpenCV 多線程防系統(tǒng)過載與mp_start_method fork多進程啟動方式。ochuman.py見 configs/base/datasets/ochuman.py提供 OCHuman 的dataset_info17 個關(guān)鍵點的名稱/顏色/類型upper/lower/左右對稱swap關(guān)系、19 條skeleton_info骨架連線、逐關(guān)節(jié)的joint_weights損失權(quán)重手腕 1.5、肘/膝 1.2其余 1.0以及sigmas用于 OKS 計算的逐關(guān)節(jié)歸一化半徑如鼻 0.026、肩 0.079、踝 0.089。evaluation每 10 個 epoch 做一次驗證指標為mAP并以AP作為保存最優(yōu)模型的依據(jù)。優(yōu)化器與學習率策略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使用 Adam 優(yōu)化器初始學習率5e-4不設(shè)梯度裁剪學習率采用 step 衰減策略前 500 個 iteration 做線性 warmup起始比例0.001在第 170 與 200 epoch 處兩次衰減總訓練210個 epoch——這是從零訓練而非微調(diào)的典型配置。通道配置 channel_cfgchannel_cfg dict( num_output_channels17, dataset_joints17, dataset_channel[[0, 1, ..., 16]], inference_channel[0, 1, ..., 16])由于 OCHuman 與 COCO 的 17 關(guān)鍵點完全對齊dataset_channel與inference_channel均為恒等映射無需做通道重排這也是跨數(shù)據(jù)集評測能夠無縫進行的前提之一。模型結(jié)構(gòu)HRNet 簡單熱圖頭model dict( typeTopDown, pretrainedhttps://download.openmmlab.com/mmpose/pretrain_models/hrnet_w32-36af842e.pth, backbonedict( typeHRNet, in_channels3, extradict( stage1dict(num_modules1, num_branches1, blockBOTTLENECK, num_blocks(4, ), num_channels(64, )), stage2dict(num_modules1, num_branches2, blockBASIC, num_blocks(4, 4), num_channels(32, 64)), stage3dict(num_modules4, num_branches3, blockBASIC, num_blocks(4, 4, 4), num_channels(32, 64, 128)), stage4dict(num_modules3, num_branches4, blockBASIC, num_blocks(4, 4, 4, 4), num_channels(32, 64, 128, 256)))), keypoint_headdict( typeTopdownHeatmapSimpleHead, in_channels32, out_channelschannel_cfg[num_output_channels], num_deconv_layers0, extradict(final_conv_kernel1, ), loss_keypointdict(typeJointsMSELoss, use_target_weightTrue)), train_cfgdict(), test_cfgdict(flip_testTrue, post_processdefault, shift_heatmapTrue, modulate_kernel11))檢測器類型為TopDown見 mmpose/models/detectors/top_down.py即標準的 top-down 熱圖回歸范式HRNet骨干保持高分辨率表示stage1 用 1 個 BOTTLENECK 模塊、單分支 64 通道stage2~stage4 依次擴展為 2/3/4 分支通道寬度逐級加倍w32 即主分支 32 通道最高分辨率分支始終保留 32 通道配 64/128/256 的并行低分辨率分支TopdownHeatmapSimpleHead直接接骨干輸出in_channels32num_deconv_layers0表示不使用反卷積上采樣只保留 1x1 卷積輸出 17 通道熱圖因為 HRNet 本身輸出已是高分辨率損失為JointsMSELoss見 mmpose/models/losses/mse_loss.pyuse_target_weightTrue啟用逐關(guān)節(jié)加權(quán)對應上文joint_weights測試配置中flip_testTrue開啟水平翻轉(zhuǎn)測試對原始與翻轉(zhuǎn)圖分別推理再融合熱圖post_processdefault、shift_heatmapTrue、modulate_kernel11對應高斯調(diào)制解碼參數(shù)。注意 mmpose/core/evaluation/top_down_eval.py 中keypoints_from_heatmaps的注釋調(diào)制核大小需與訓練熱圖高斯 sigma 匹配——K17 for sigma3 and k11 for sigma2此處訓練TopDownGenerateTarget, sigma2故modulate_kernel11嚴格對應。數(shù)據(jù)配置 data_cfg 與 NMS 參數(shù)data_cfg dict( image_size[192, 256], heatmap_size[48, 64], num_output_channels17, num_joints17, dataset_channel..., inference_channel..., soft_nmsFalse, nms_thr1.0, oks_thr0.9, vis_thr0.2, use_gt_bboxTrue, det_bbox_thr0.0, bbox_filedata/coco/person_detection_results/COCO_val2017_detections_AP_H_56_person.json)image_size[192, 256]W×H、heatmap_size[48, 64]即輸入 256x192、熱圖下采樣 4 倍為 64x48384x288 配置則為[288, 384]與[72, 96]use_gt_bboxTrue是本文檔評測結(jié)果成立的關(guān)鍵——使用 GT 框而非檢測框bbox_file指向 COCO 的檢測結(jié)果 JSON供檢測框模式使用GT 模式下不生效soft_nmsFalse、nms_thr1.0、oks_thr0.9、vis_thr0.2控制多候選人的后處理關(guān)鍵點置信度高于vis_thr才參與 rescore高于oks_thr的框在 OKS NMS 中被抑制。訓練/驗證數(shù)據(jù)管線train_pipeline [ dict(typeLoadImageFromFile), dict(typeTopDownRandomFlip, flip_prob0.5), dict(typeTopDownHalfBodyTransform, num_joints_half_body8, prob_half_body0.3), dict(typeTopDownGetRandomScaleRotation, rot_factor40, scale_factor0.5), dict(typeTopDownAffine), dict(typeToTensor), dict(typeNormalizeTensor, mean[0.485, 0.456, 0.406], std[0.229, 0.224, 0.225]), dict(typeTopDownGenerateTarget, sigma2), dict(typeCollect, keys[img, target, target_weight], meta_keys[...]), ] val_pipeline test_pipeline [ LoadImageFromFile → TopDownAffine → ToTensor → NormalizeTensor → Collect(keys[img]) ]訓練側(cè)數(shù)據(jù)增強隨機水平翻轉(zhuǎn)50% 概率、半身變換30% 概率、至少 8 個關(guān)鍵點、隨機縮放旋轉(zhuǎn)旋轉(zhuǎn) ±40°、尺度 0.5、仿射變換、ImageNet 均值方差歸一化、高斯熱圖目標生成sigma2384x288 配置中為sigma3以匹配更大的熱圖驗證/測試管線保持最小化僅做仿射變換與歸一化不做任何隨機增強保證評測可復現(xiàn)Collect負責聚合張量與meta_keys元信息image_file/center/scale/rotation/bbox_score/flip_pairs等供推理與后處理使用。數(shù)據(jù)劃分COCO 訓練、OCHuman 評測data_root data/ochuman data dict( samples_per_gpu64, workers_per_gpu2, val_dataloaderdict(samples_per_gpu32), test_dataloaderdict(samples_per_gpu32), traindict(typeTopDownCocoDataset, ann_filedata/coco/annotations/person_keypoints_train2017.json, img_prefixdata/coco/train2017/, ...), valdict(typeTopDownOCHumanDataset, ann_filef{data_root}/annotations/ochuman_coco_format_val_range_0.00_1.00.json, img_prefixf{data_root}/images/, ...), testdict(typeTopDownOCHumanDataset, ann_filef{data_root}/annotations/ochuman_coco_format_test_range_0.00_1.00.json, img_prefixf{data_root}/images/, ...))這一段的交叉評測設(shè)定是整個配置的核心train使用TopDownCocoDataset讀 COCO 官方標注val/test使用TopDownOCHumanDataset定義于 topdown_ochuman_dataset.py繼承自TopDownCocoDataset讀取 OCHuman 的 COCO 格式標注val 范圍 0.00~1.00 與 test 范圍 0.00~1.00 兩個 JSON。數(shù)據(jù)集類內(nèi)部_get_db通過assert self.use_gt_bbox強制要求 GT 框模式見 topdown_ochuman_dataset.py這也印證了本文檔結(jié)果基于 GT 框的事實。數(shù)據(jù)準備OCHuman 官方提供的是與 COCO 兼容的標注格式倉庫約定按以下目錄結(jié)構(gòu)放置data/ochuman/ ├── annotations/ │ ├── ochuman_coco_format_val_range_0.00_1.00.json │ └── ochuman_coco_format_test_range_0.00_1.00.json └── images/COCO 側(cè)則需準備data/coco/annotations/person_keypoints_train2017.json與data/coco/train2017/圖像。數(shù)據(jù)集的具體下載與目錄組織方式可參考 docs/zh_cn/data_preparation.md 或英文版 docs/en/data_preparation.md 中關(guān)于 COCO 的說明并按上述 OCHuman 目錄結(jié)構(gòu)放置標注與圖像。訓練與評測命令單卡訓練python tools/train.py configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman/hrnet_w32_ochuman_256x192.py訓練入口為 tools/train.py。由于本配置在 COCO 上從零訓練 210 個 epoch屬于完整訓練任務建議使用分布式訓練腳本 tools/dist_train.shbash tools/dist_train.sh configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman/hrnet_w32_ochuman_256x192.py 88為 GPU 卡數(shù)可按實際環(huán)境調(diào)整。測試與評估python tools/test.py configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman/hrnet_w32_ochuman_256x192.py \ /path/to/checkpoint.pth --eval mAPmmpose/apis/test.py 負責加載模型與數(shù)據(jù)tools/test.py 提供命令行入口其中--eval mAP指定評測指標mAP是 OCHuman 數(shù)據(jù)集唯一支持的指標見下方評估實現(xiàn)還可使用--out指定結(jié)果文件、--work-dir指定工作目錄、--fuse-conv-bn融合 BN 加速推理、--gpu-id指定 GPU、--cfg-options覆蓋任意配置項例如--cfg-options data_cfg.image_size[288,384]。分布式測試可運行bash tools/dist_test.sh configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman/hrnet_w32_ochuman_256x192.py \ /path/to/checkpoint.pth 8 --eval mAP注意測試配置中的val/test均指向 OCHuman 標注因此無論--eval mAP默認評估哪個 split得到的都是遮擋場景下的評測指標。評估原理mAP 與 OKS 的源碼級解讀OCHuman 的評測指標mAP走的是 COCO 關(guān)鍵點評估協(xié)議。從 topdown_coco_dataset.py 可見allowed_metrics [mAP]且evaluate()對metricPCK等其他指標會直接拋出KeyError——這一點在測試用例 tests/test_datasets/test_top_down_dataset.py 中也有驗證with pytest.raises(KeyError): _ custom_dataset.evaluate(results, metricPCK)。完整的評估鏈路如下結(jié)果聚合evaluate()將每張圖的預測關(guān)鍵點、center/scale/area/score、bbox_id匯總并按bbox_id去重排序_sort_and_unique_bboxesRescore重打分對每個候選實例用關(guān)鍵點置信度與可見性閾值vis_thr計算關(guān)鍵點平均分與檢測框分數(shù)融合得到最終score見 topdown_coco_dataset.pyOKS NMS按 OKSObject Keypoint Similarity相似度抑制重復候選閾值由oks_thr0.9控制COCOeval寫入result_keypoints.json后調(diào)用COCOeval(self.coco, coco_det, keypoints, self.sigmas)完成評估與匯總見_do_python_keypoint_evaltopdown_coco_dataset.py輸出的統(tǒng)計量包括AP、AP .5、AP .75、AP (M)、AP (L)、AR、AR .5、AR .75、AR (M)、AR (L)。其中 OKS 的逐關(guān)節(jié) sigma 正是來自 configs/base/datasets/ochuman.py 的sigmas字段與 COCO 官方數(shù)值一致說明評估協(xié)議與 COCO 完全兼容。推理后處理熱圖解碼的關(guān)鍵參數(shù)模型輸出的是 17 通道熱圖解碼流程由 mmpose/core/evaluation/top_down_eval.py 的keypoints_from_heatmaps實現(xiàn)其post_process參數(shù)支持None / default / unbiased / megvii四種模式default對熱圖做高斯調(diào)制_gaussian_blur核大小modulate_kernel后取最大值位置對應配置中的默認值unbiased采用 Distribution-Aware 無偏解碼CVPR2020需配合kernel 0megviiMegvii 風格解碼啟用flip_testTrue時原始圖與水平翻轉(zhuǎn)圖的熱圖會先各自解碼再融合shift_heatmapTrue負責翻轉(zhuǎn)熱圖的坐標回移。本文配置采用post_processdefaultmodulate_kernel11與訓練sigma2匹配配合翻轉(zhuǎn)測試是文檔結(jié)果表背后的標準推理設(shè)置。擴展閱讀同目錄下的其他評測配置OCHuman 目錄下configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/ochuman除本文詳述的 4 個 HRNet 配置外還包含兩類同設(shè)定評測ResNet 系列res50/res101/res152 × 256x192/384x288共 6 個配置與對應結(jié)果文檔 resnet_ochuman.md、resnet_ochuman.ymlViTPose 系列ViTPose_small/base/large/huge_ochuman_256x192.py四個配置。以 ViTPose_small_ochuman_256x192.py 為例其data_cfg、train/val/test劃分與 HRNet 配置完全一致同為 COCO 訓練、OCHuman 評測、GT 框差異僅體現(xiàn)在模型部分骨干換成typeViTimg_size(256,192)、patch_size16、embed_dim384、depth12、num_heads12、mlp_ratio4、drop_path_rate0.3head 變?yōu)門opdownHeatmapSimpleHead配 2 層反卷積上采樣num_deconv_layers2、num_deconv_filters(256,256)、num_deconv_kernels(4,4)輸入通道改為in_channels384base 為 768。這組配置可直接用于對比 CNN 骨干與 ViT 骨干在遮擋場景下的魯棒性差異。小結(jié)圍繞 hrnet_ochuman.md 這份評測文檔本文完整梳理了OCHuman 數(shù)據(jù)集的重遮擋評測定位、COCO 訓練 → OCHuman 測試的交叉評測范式、HRNet w32/w48 在兩種分辨率下的官方指標AP 0.591~0.616、hrnet_w32_ochuman_256x192.py 的逐段配置語義以及從數(shù)據(jù)準備、訓練、測試到 OKS/mAP 評估協(xié)議與熱圖解碼后處理的完整鏈路。如果你希望在遮擋人體姿態(tài)估計上復現(xiàn)或改進基線這份配置與文檔組合就是最直接的起點。贊分享人工智能計算機視覺深度學習【免費下載鏈接】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點擊查看免費下載相關(guān)推薦ViTPose 倉庫 PoseTrack18 上的 HRNet 人體姿態(tài)估計COCO 預訓練微調(diào)配置與評估全解析ViTPose 倉庫 PoseTrack18 上的 HRNet 人體姿態(tài)估計COCO 預訓練微調(diào)配置與評估全解析 本文以 configs/body/2d_kp人工智能計算機視覺深度學習ViTPose 倉庫 Associative Embedding HRNet COCO 自底向上人體姿態(tài)估計配置全解析ViTPose 倉庫 Associative Embedding HRNet COCO 自底向上人體姿態(tài)估計配置全解析 導讀 本文以 hrnet_coco.人工智能計算機視覺深度學習基于 HRNet 的 COCO 人體姿態(tài)估計ViTPose 倉庫 topdown heatmap 配置全解析基于 HRNet 的 COCO 人體姿態(tài)估計ViTPose 倉庫 topdown heatmap 配置全解析 導讀 本文以 ViTPose 倉庫中 hrnet人工智能計算機視覺深度學習創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考