AI Wiki中文/EN

姿态估计:找到关节、连对人,再检查坐标

Pose estimation

实现热图CNN及完整梯度,解码坐标、用PAF关联关节,并区分OKS、MPJPE与三维姿态的歧义。

本页目录直觉理解数学与方法代码实现局限与误解实验与练习研究脉络

找到手腕,还得知道是谁的手腕

照片里,两个人的手臂交叉在一起。找到四个手腕只完成了一半任务:系统还得把每个手腕接到正确的手肘和人身上。接错之后,画面中可能出现一副看似合理、却不属于任何人的骨架。

人体姿态估计要定位具有明确名称的身体关节;多人场景还要把它们分配给不同个体。二维姿态使用图像坐标,三维姿态使用指定参考系中的空间坐标。本篇讨论有关节的人体骨架。估计刚体的旋转和平移,也是“姿态估计”的一种用法,但属于另一个问题。骨架本身也不直接给出身份、意图或动作类别。

对于一个人和K类关节,可以先用一组XY坐标加标注标记描述姿态。COCO中,0表示未标注,1表示已标注但不可见,2表示已标注且可见。被挡住的手肘仍可能有标注位置。单看坐标是不是零,不能判断数据是否缺失。标注契约

多人问题常有两种组织方式。自顶向下先检测人,裁出每个人,再估计其关节;自底向上先在整图寻找部位,再将它们组合起来。前一种可能在关节估计开始前就因漏检人框而失败;后一种即使位置找对,也可能配错归属。这是在区分处理流程,并非给准确率排座次。问题分解

我们将实现一个小型热图CNN,再用独立、可控制的例子讨论关联与三维几何。把它们分开,才能知道每项结果究竟来自哪段计算。

由实际程序计算的双峰坐标期望与双人真值PAF关联,显示期望可能不在峰上,关节还需要正确配对。
原创计算图。上方解码与关联例子相互独立,下方损失仅来自小CNN的合成样本更新。

把位置、归属和测量分开

坐标离不开参考系

裁剪图像会改变坐标的含义。将原图到裁剪图的二维仿射变换写成:

[x′y′]=A[xy1],A∈R2×3.\begin{bmatrix}x'\\y'\end{bmatrix}=A\begin{bmatrix}x\\y\\1\end{bmatrix},\qquad A\in\mathbb R^{2\times3}.

解码后的预测要通过逆变换回到原图。需要分清图像宽高与热图宽高、XY与数组行列,以及像素中心规则与端点规则。一个看上去处处一致的一像素偏移,可能是几何处理出了错,而非模型能力不足。

DeepPose直接回归相对于人框归一化的关节坐标,并通过级联逐步细化。它让坐标预测利用共享的图像证据,而不是把每个关节完全孤立处理。归一化回归

本例在零起始网格上用x′=W−1−x进行水平翻转,随后置换左右关节名称。只镜像坐标却不交换标签,就等于拿右手腕的位置去教“左手腕”。

热图把一个点变成空间学习目标

对于坐标为qj的已标注关节j,本例在热图网格点p上建立未归一化的高斯目标。mj在关节有标注时为1,否则为0。K张热图各含H×W个像素:

Gj(p)=exp⁡(−∥p−qj∥222σ2),L=∑j,pmj(G^j(p)−Gj(p))2HW∑jmj.G_j(p)=\exp\left(-\frac{\|p-q_j\|_2^2}{2\sigma^2}\right),\qquad L=\frac{\sum_{j,p}m_j\bigl(\widehat G_j(p)-G_j(p)\bigr)^2}{HW\sum_jm_j}.

Sigma是正标准差,单位是热图像素。目标越宽,学习信号分布到的邻近像素越多;这不会改变标注的真实位置。若没有任何已标注关节,本例把损失与梯度都设为零;上式只在分母为正时使用。

对任一预测热图元素,平方误差的导数为:

∂L∂G^j(p)=2mj(G^j(p)−Gj(p))HW∑jmj.\frac{\partial L}{\partial\widehat G_j(p)}=\frac{2m_j\bigl(\widehat G_j(p)-G_j(p)\bigr)}{HW\sum_jm_j}.

这与本例代码的归一方式严格对应,不代表所有姿态库都采用同一分母。固定版本MMPose的MSRA编码器会把目标中心舍入,并采用半径3σ的裁剪高斯窗口。本例保留连续中心、不截断。该编码器的默认解码还会在寻找最大值之后细化坐标,本例的原始argmax不做这一步。目标生成、编码器

原始argmax只能选一个网格位置。因此,以(4.25,4.75)为中心的目标会解码为(4,5);即使模型尚未引入误差,也已有约0.354个热图像素的误差。本例遇到并列峰值时,选择按行展开后的第一个位置。与固定MMPose最大值辅助函数不同,本例不会把非正峰值对应的坐标改成无效值。生产解码器需要明确规定置信度和缺失判定。最大值解码

可微的坐标,未必是可能性高的坐标

积分回归先把空间分数图归一化,再取坐标期望。对于本例零起始网格与正温度τ:

Pj(p)=exp⁡(zj(p)/τ)∑rexp⁡(zj(r)/τ),μj=∑pPj(p)p.P_j(p)=\frac{\exp(z_j(p)/\tau)}{\sum_r\exp(z_j(r)/\tau)},\qquad \mu_j=\sum_pP_j(p)p.

计算指数前,先减去缩放后最大的logit。对于固定分数图,温度控制分布集中程度;它本身不是经过校准的不确定性估计。根据softmax导数,可以直接得到坐标的导数:

∂μj,d∂zj(p)=Pj(p)τ(pd−μj,d).\frac{\partial\mu_{j,d}}{\partial z_j(p)}=\frac{P_j(p)}{\tau}\bigl(p_d-\mu_{j,d}\bigr).

于是,坐标损失可以训练生成热图的网络。不过,如果概率各有一半落在(1,2)和(5,2),期望位置就是(3,2)——这个两点分布在此处根本没有概率。可微性绕过了硬解码的求导障碍,却没有解决两个可能的手腕究竟哪一个才对。积分公式

保留细节,同时收集上下文

定位手腕需要局部细节;判断它是否连接附近某个手肘,需要看得更远。Stacked Hourglass反复压缩、扩展空间特征,通过相加的跳跃连接结合不同尺度,并加入中间监督。本篇所读v1堆叠两个沙漏模块;它所说的特征“自底向上/自顶向下”处理,与多人关节的自底向上分组不是同一术语。Hourglass首版

HRNet在保留较高分辨率分支的同时,逐步加入更低分辨率分支,并反复交换信息。低分辨率特征经过投影、上采样,高分辨率特征则下采样后参与融合。它的入口stem仍会降低图像分辨率。“高分辨率”描述的是特征层级,而非每层始终保留原图所有像素。HRNet方法

沿着肢体寻找关联证据

部位亲和场,即PAF,为一种肢体连接在每个像素保存二维方向。标注肢体在有限矩形条带内贡献单位方向;同类型肢体重叠时取平均,方向相反还可能相互抵消。候选端点a、b的关联分数为:

E(a,b)=∫01F(a+u(b−a))⊤b−a∥b−a∥2 du.E(a,b)=\int_0^1F\bigl(a+u(b-a)\bigr)^\top\frac{b-a}{\|b-a\|_2}\,du.

这个分数沿候选连线采样方向证据。它对u归一化,并不再乘肢体长度。原方法对每种肢体求最大权二分匹配,再利用简化的骨架结构组装身体。全文所说的贪心解析,不等于“每次拿走剩下分数最大的边”。PAF构造与匹配

下面原创的双人例子使用真值构造的方向场、双线性采样和精确的小规模子集动态规划。若分数矩阵两行为[0.9,0.8]和[0.8,0],先拿0.9会输给总分1.6的两条交叉分配。本例允许候选不匹配,因此弱关联或负分边不必强行变成肢体。

评测之前先说清测量什么

单纯像素误差会把远处小脸上的两像素误差与近处大躯干上的两像素误差同等处理。COCO的对象关键点相似度OKS引入对象尺度与关节特定常数。令尺度平方A等于分割面积,dj为位置误差,vj为标注可见性,并取κj=2σj:

OKS⁡=∑j1[vj>0]exp⁡ ⁣(−dj22Aκj2)∑j1[vj>0],κj=2σj.\operatorname{OKS}=\frac{\sum_j\mathbf1[v_j>0]\exp\!\left(-\frac{d_j^2}{2A\kappa_j^2}\right)}{\sum_j\mathbf1[v_j>0]},\qquad \kappa_j=2\sigma_j.

这里的可见性来自真值,不能用预测的单关节可见性替代。固定评测器纳入已标注的遮挡关节,每张图最多保留20个关键点检测结果,并对未标注或需忽略的人有特殊处理。本例的单人函数在没有已标注关节时返回None,没有实现完整匹配和忽略逻辑。官方定义、固定评测器、关节常数

一个人的OKS不是AP。COCO关键点AP还涉及带分数的检测、匹配,以及从0.50到0.95、步长0.05的多个OKS阈值下的精确率—召回率。PCK是另一类指标,统计归一化距离小于指定阈值的比例;比较结果前,先说明归一化方式与阈值。COCO指标、PCK实现

三维预测的平均每关节位置误差MPJPE,是在共同单位、共同参考系下计算欧氏距离的平均值。需要说明坐标是绝对位置、相对根节点,还是经过其他变换对齐。分别减去两副姿态的根位置只消除平移,不完成尺度或旋转对齐。较低的Procrustes对齐误差,与准确恢复相机坐标回答的不是同一个问题。MPJPE对齐选项

运行完整的小规模计算

使用Python 3.12和NumPy 1.26.4。将下面代码保存为pose_geometry.py,运行python pose_geometry.py。程序包含完整的3×3卷积→ReLU→1×1热图网络、全部127参数的梯度、输入梯度以及一次更新。输入由已知目标构造的合成信号与坐标通道组成,是受控计算,不是独立测试集上的姿态基准。

PAF例子的方向场由已知肢体端点生成,与CNN分开;CNN没有学会这个场。三维部分计算几何与指标,不训练二维到三维的映射。这里没有通过某个库调用暗中引入预训练权重或完整HRNet/OpenPose模型。

"""Original pose teaching operators: heatmaps, gradients, PAFs and metrics.

Single-person heatmap CNN plus separate oracle-field association fixtures.
Not HRNet/OpenPose training, a COCO evaluator, or a learned 3D lifting model.
"""
import json
from functools import lru_cache
import numpy as np


def finite(value, rank):
    x = np.asarray(value, float)
    if x.ndim != rank or not np.isfinite(x).all():
        raise ValueError('finite array of the specified rank required')
    return x


def size2(shape):
    if len(shape) != 2 or any(type(n) is not int or n < 1 for n in shape):
        raise ValueError('positive integer height and width required')
    return tuple(shape)


def visibility(value, count):
    v = np.asarray(value)
    if v.shape != (count,) or v.dtype.kind not in 'iu' or not np.isin(v, [0, 1, 2]).all():
        raise ValueError('one integer visibility flag 0,1,2 per joint required')
    return v > 0


def gaussian_targets(points, flags, shape, sigma=1.):
    """Continuous centers, untruncated Gaussian values; not rounded MSRA targets."""
    points = finite(points, 2)
    if points.shape[1] != 2 or len(points) == 0 or not np.isfinite(sigma) or sigma <= 0:
        raise ValueError('nonempty XY points and positive sigma required')
    h, w = size2(shape)
    valid = visibility(flags, len(points))
    yy, xx = np.indices((h, w))
    target = np.exp(-((xx[None]-points[:, 0, None, None])**2
                     +(yy[None]-points[:, 1, None, None])**2)/(2*sigma*sigma))
    target[~valid] = 0
    return target, valid


def heatmap_loss(predicted, target, flags):
    p, y = finite(predicted, 3), finite(target, 3)
    if p.shape != y.shape or min(p.shape) < 1:
        raise ValueError('matching nonempty K,H,W maps required')
    valid = visibility(flags, len(p))
    difference = (p-y)*valid[:, None, None]
    divisor = int(valid.sum())*p.shape[1]*p.shape[2]
    if divisor == 0:
        return 0., np.zeros_like(p)
    return float(np.sum(difference**2)/divisor), 2*difference/divisor


def argmax_xy(heatmaps):
    """Raw row-major argmax; no confidence gate or quarter-pixel refinement."""
    h = finite(heatmaps, 3)
    if min(h.shape) < 1:
        raise ValueError('nonempty K,H,W heatmaps required')
    flat = h.reshape(len(h), -1)
    index = flat.argmax(axis=1)
    return np.stack([index % h.shape[2], index//h.shape[2]], axis=-1), flat.max(axis=1)


def integral_xy(logits, temperature=1.):
    z = finite(logits, 3)
    if min(z.shape) < 1 or not np.isfinite(temperature) or temperature <= 0:
        raise ValueError('nonempty logits and positive temperature required')
    scaled = z/temperature
    scaled -= scaled.max(axis=(1, 2), keepdims=True)
    probability = np.exp(scaled)
    probability /= probability.sum(axis=(1, 2), keepdims=True)
    y, x = np.indices(z.shape[1:])
    xy = np.stack([(probability*x).sum(axis=(1, 2)), (probability*y).sum(axis=(1, 2))], axis=-1)
    return xy, probability


def integral_backward(gradient, probability, temperature=1.):
    p, g = finite(probability, 3), finite(gradient, 2)
    if min(p.shape) < 1 or g.shape != (len(p), 2) or np.any(p < 0) or not np.allclose(p.sum(axis=(1, 2)), 1):
        raise ValueError('normalized probabilities and K,2 coordinate gradients required')
    if not np.isfinite(temperature) or temperature <= 0:
        raise ValueError('positive temperature required')
    y, x = np.indices(p.shape[1:])
    mean_x = (p*x).sum(axis=(1, 2))
    mean_y = (p*y).sum(axis=(1, 2))
    return p*(g[:, 0, None, None]*(x-mean_x[:, None, None])
              +g[:, 1, None, None]*(y-mean_y[:, None, None]))/temperature


def affine_points(points, matrix):
    p, a = finite(points, 2), finite(matrix, 2)
    if p.shape[1] != 2 or a.shape != (2, 3):
        raise ValueError('XY points and a2x3 affine transform required')
    return np.c_[p, np.ones(len(p))] @ a.T


def flip_pose(points, width, permutation):
    p = finite(points, 2)
    order = np.asarray(permutation)
    if p.shape[1] != 2 or type(width) is not int or width < 1 or order.shape != (len(p),) or order.dtype.kind not in 'iu' or sorted(order.tolist()) != list(range(len(p))):
        raise ValueError('XY points, positive width and full joint permutation required')
    p = p.copy()
    p[:, 0] = width-1-p[:, 0]
    return p[order]


def paf_target(starts, ends, shape, radius=.75):
    a, b = finite(starts, 2), finite(ends, 2)
    if a.shape != b.shape or a.shape[1] != 2 or not np.isfinite(radius) or radius <= 0:
        raise ValueError('matching limb endpoint arrays and positive strip radius required')
    h, w = size2(shape)
    field, count = np.zeros((h, w, 2)), np.zeros((h, w))
    yy, xx = np.indices((h, w))
    for start, end in zip(a, b):
        length = np.linalg.norm(end-start)
        if length == 0:
            raise ValueError('zero-length limbs have no direction')
        unit = (end-start)/length
        dx, dy = xx-start[0], yy-start[1]
        along = dx*unit[0]+dy*unit[1]
        across = np.abs(-dx*unit[1]+dy*unit[0])
        inside = (along >= 0) & (along <= length) & (across <= radius)
        field[inside] += unit
        count[inside] += 1
    return field/np.maximum(count, 1)[..., None]


def paf_score(field, start, end, samples=32):
    f, a, b = finite(field, 3), finite(start, 1), finite(end, 1)
    if min(f.shape) < 1 or f.shape[2] != 2 or a.shape != (2,) or b.shape != (2,) or type(samples) is not int or samples < 1:
        raise ValueError('HxWx2 field, endpoints and positive sample count required')
    h, w = f.shape[:2]
    for point in [a, b]:
        if np.any(point < 0) or point[0] > w-1 or point[1] > h-1:
            raise ValueError('endpoints must be inside the pixel-center grid')
    length = np.linalg.norm(b-a)
    if length == 0:
        raise ValueError('zero-length candidate')
    direction = (b-a)/length
    score = 0.
    for t in (np.arange(samples)+.5)/samples:
        x, y = a+t*(b-a)
        x0, y0 = int(x), int(y)
        x1, y1 = min(x0+1, w-1), min(y0+1, h-1)
        dx, dy = x-x0, y-y0
        value = ((1-dy)*((1-dx)*f[y0, x0]+dx*f[y0, x1])
                 +dy*((1-dx)*f[y1, x0]+dx*f[y1, x1]))
        score += value @ direction/samples
    return float(score)


def best_pairs(scores, threshold=0.):
    """Exact tiny maximum-weight partial matching via subset DP, not Hungarian.

    At most12 columns. Unmatched rows are allowed; only scores above threshold
    are eligible. Equal total scores retain the earlier decision (skip first).
    """
    scores = finite(scores, 2)
    n, cols = scores.shape
    if cols > 12 or n > 50 or not np.isfinite(threshold):
        raise ValueError('tiny finite problem required: at most50 rows/12 columns')
    @lru_cache(None)
    def solve(row, used):
        if row == n:
            return 0., ()
        best, pairs = solve(row+1, used)
        for col in range(cols):
            if not used & (1 << col) and scores[row, col] > threshold:
                rest, tail = solve(row+1, used | (1 << col))
                candidate = scores[row, col]+rest
                if candidate > best:
                    best, pairs = float(candidate), ((row, col),)+tail
        return best, pairs
    return solve(0, 0)


def oks(predicted, truth, flags, area, sigmas):
    """One annotated person. sigmas are COCO-style sigma, with kappa=2*sigma.

    Not the full evaluator: all-unlabeled GT returnsNone instead of running the
    expanded-bbox ignore matching branch. Object area is supplied, not inferred.
    """
    p, g = finite(predicted, 2), finite(truth, 2)
    sigma = finite(sigmas, 1)
    if p.shape != g.shape or p.shape[1] != 2 or sigma.shape != (len(p),) or np.any(sigma <= 0) or not np.isfinite(area) or area <= 0:
        raise ValueError('matching XY poses, positive area and one positive sigma per joint required')
    valid = visibility(flags, len(p))
    if not valid.any():
        return None
    error2 = ((p-g)**2).sum(axis=1)
    return float(np.exp(-error2[valid]/(2*area*(2*sigma[valid])**2)).mean())


def project(points, focal=(100., 100.), center=(0., 0.)):
    p = finite(points, 2)
    f, c = finite(focal, 1), finite(center, 1)
    if p.shape[1] != 3 or np.any(p[:, 2] <= 0) or f.shape != (2,) or c.shape != (2,) or np.any(f <= 0):
        raise ValueError('XYZ points in front of camera, positive focal lengths and XY center required')
    return p[:, :2]/p[:, 2, None]*f+c


def mpjpe(predicted, truth, flags, root=None):
    p, g = finite(predicted, 2), finite(truth, 2)
    if p.shape != g.shape or p.shape[1] != 3:
        raise ValueError('matching K,3 joint coordinates in one common unit required')
    valid = visibility(flags, len(p))
    if not valid.any():
        return None
    if root is not None:
        if type(root) is not int or not 0 <= root < len(p) or not valid[root]:
            raise ValueError('a labeled root joint index required')
        p, g = p-p[root], g-g[root]
    return float(np.linalg.norm(p[valid]-g[valid], axis=1).mean())


def conv(x, kernel, bias):
    h, w = x.shape[:2]
    k = kernel.shape[0]
    pad = k//2
    xp = np.pad(x, ((pad, pad), (pad, pad), (0, 0)))
    out = np.broadcast_to(bias, (h, w, len(bias))).copy()
    for y in range(k):
        for z in range(k):
            out += xp[y:y+h, z:z+w] @ kernel[y, z]
    return out


def conv_backward(x, kernel, gradient):
    h, w = x.shape[:2]
    k, pad = kernel.shape[0], kernel.shape[0]//2
    xp = np.pad(x, ((pad, pad), (pad, pad), (0, 0)))
    dxp, dk = np.zeros_like(xp), np.zeros_like(kernel)
    for y in range(k):
        for z in range(k):
            dk[y, z] = np.einsum('hwc,hwf->cf', xp[y:y+h, z:z+w], gradient)
            dxp[y:y+h, z:z+w] += gradient @ kernel[y, z].T
    return dxp[pad:pad+h, pad:pad+w], [dk, gradient.sum(axis=(0, 1))]


def parameters(seed=4):
    rng = np.random.default_rng(seed)
    return [rng.normal(0, .15, (3, 3, 3, 4)), np.full(4, .1),
            rng.normal(0, .15, (1, 1, 4, 3)), np.zeros(3)]


def forward(image, p):
    x = finite(image, 3)
    if min(x.shape) < 1 or x.shape[2] != 3:
        raise ValueError('nonempty H,W,3 input required')
    z = conv(x, p[0], p[1])
    a = np.maximum(z, 0)
    out = conv(a, p[2], p[3]).transpose(2, 0, 1)
    return out, (x, z, a)


def backward(p, cache, gradient):
    x, z, a = cache
    grad = finite(gradient, 3)
    if grad.shape != (3, *x.shape[:2]):
        raise ValueError('3,H,W heatmap gradient required')
    da, head = conv_backward(a, p[2], grad.transpose(1, 2, 0))
    dx, body = conv_backward(x, p[0], da*(z > 0))
    return body+head, dx


def demo():
    shape = (16, 16)
    joints = np.array([[4.25, 4.75], [10.5, 6.25], [7.5, 12.]])
    flags = np.array([2, 1, 2])
    target, _ = gaussian_targets(joints, flags, shape, sigma=1.)
    y, x = np.indices(shape)
    gray = (target*np.array([.8, .5, 1.])[:, None, None]).sum(axis=0)
    image = np.stack([gray, x/15, y/15], axis=-1)
    p = parameters()
    initial, cache = forward(image, p)
    before, grad = heatmap_loss(initial, target, flags)
    dp, dx = backward(p, cache, grad)
    for parameter, derivative in zip(p, dp):
        parameter -= .1*derivative
    after = heatmap_loss(forward(image, p)[0], target, flags)[0]
    assert after < before
    peaks, _ = argmax_xy(target)
    bimodal = np.full((1, 5, 7), -1000.)
    bimodal[0, 2, [1, 5]] = 0
    mean, _ = integral_xy(bimodal)
    start = np.array([[2., 2.], [2., 6.]])
    end = np.array([[8., 6.], [8., 2.]])
    field = paf_target(start, end, (9, 11))
    scores = np.array([[paf_score(field, a, b) for b in end] for a in start])
    total, pairs = best_pairs(scores)
    xyz = np.array([[1., 2., 10.], [2., 3., 12.], [-1., 1., 8.]])
    assert np.allclose(project(xyz), project(2*xyz))
    return {'parameters': sum(a.size for a in p), 'lossBefore': before, 'lossAfterOneStep': after,
            'inputGradientNorm': float(np.linalg.norm(dx)), 'targetArgmaxXY': peaks.tolist(),
            'targetCoordinateError': np.linalg.norm(peaks-joints, axis=1).tolist(),
            'twoPeakExpectationXY': mean.tolist(), 'pafScores': scores.tolist(),
            'pafPairs': [list(pair) for pair in pairs], 'pafTotal': total,
            'onePersonOKS': oks(joints+2, joints, flags, area=100., sigmas=np.full(3, .1)),
            'sameProjectionDifferent3D': True,
            'scope': 'synthetic three-joint CNN step, separate oracle PAF and geometry fixtures; not a pose benchmark'}


if __name__ == '__main__':
    print(json.dumps(demo(), indent=2))

以下为已检查环境中的输出,不同平台的浮点末位可能略有差别:

{
  "parameters": 127,
  "lossBefore": 0.025322528841920867,
  "lossAfterOneStep": 0.023160444829314047,
  "inputGradientNorm": 0.002874659391743485,
  "targetArgmaxXY": [
    [
      4,
      5
    ],
    [
      10,
      6
    ],
    [
      7,
      12
    ]
  ],
  "targetCoordinateError": [
    0.3535533905932738,
    0.5590169943749475,
    0.5
  ],
  "twoPeakExpectationXY": [
    [
      3.0,
      2.0
    ]
  ],
  "pafScores": [
    [
      0.7761653019831731,
      0.34695847234595634
    ],
    [
      0.34695847234595634,
      0.7761653019831731
    ]
  ],
  "pafPairs": [
    [
      0,
      0
    ],
    [
      1,
      1
    ]
  ],
  "pafTotal": 1.5523306039663463,
  "onePersonOKS": 0.3678794411714424,
  "sameProjectionDifferent3D": true,
  "scope": "synthetic three-joint CNN step, separate oracle PAF and geometry fixtures; not a pose benchmark"
}

一次更新使损失从0.0253225降到0.0231604。它检查的是合成样本上的下降,不是泛化能力。targetArgmaxXY测量目标热图的解码,不能拿来报告训练网络的定位准确率。交叉肢体方向场支持正确配对,尽管错误连线更短。

固定通道数时,CNN计算量随图像面积线性增长;一般卷积的计算量是O(HWk²CinCout)。热图存储为O(KHW)。对于一种肢体,两端分别有Na、Nb个候选,每条候选连线采样S次,PAF分数构造需要O(NaNbS)。不计分配元组复制时,小匹配器的状态转移计算为O(NaNb2^Nb);缓存分配元组后,存储上界为O(Na2^Nb min(Na,Nb))。程序把列数限制在12以内,不能替代可扩展的生产分配算法。

骨架看起来合理,也可能是错的

遮挡与归属。 网络可以借助上下文补出隐藏肢体,同时认错它属于谁。应分别测试拥挤、截断和少见姿态,报告漏检与身份交换,而不只报告成功匹配的可见关节误差。

几何与部署。 人框裁剪错误、左右标签不一致、缩放规则混用,未必能靠看几张图发现。要追踪原图到热图再返回的整个变换过程。如果健身应用依赖关节角度,还应检查角度误差与失败案例。姿态分数本身不能证明生物力学有效性,更不能直接支持医学结论。

深度歧义。 正深度下,针孔相机的图像坐标满足:

u=fxXZ+cx,v=fyYZ+cy.u=f_x\frac{X}{Z}+c_x,\qquad v=f_y\frac{Y}{Z}+c_y.

将X、Y、Z同时乘以同一个正数,u、v不变。因此,即使二维骨架完美,也不能唯一确定三维绝对尺度。代码验证了这个精确歧义。增加视角、引入已校准的尺度信息、使用学习到的人体先验,分别施加了不同的额外约束;不能悄悄假定它们已经存在。

VideoPose3D对二维关节序列使用时间卷积,并在半监督学习中引入反投影。其通常上下文包含未来帧,因果配置是另一个选择。相对根节点的姿态与全局轨迹也是分开输出,再用于透视投影。预测即使平滑且自洽,仍可能建立在错误的深度解释上。时间模型与投影

证据与人。 即使删除人脸,连续骨架仍可能暴露行为。只收集必要影像,在适当情况下按人员或录像划分评测集,并说明标注范围。本篇六篇论文用于解释若干方法变化,并不表示之后所有姿态模型都采用同一架构,也不表示当年的基准排名至今有效。

信任骨架之前,先做四个检查

1. 解释缺失关节

一个关节的可见性标记为1,另一个为0。哪些进入本篇的损失与OKS?如果两个都为0,应该怎样处理?

答案: 标记1表示已标注但被遮挡,仍参与计算;标记0不参与。本例在全部未标注时返回零损失、零梯度,单人OKS返回None,避免在没有可用关节时编出准确率。完整COCO评测器另有忽略对象处理。

2. 计算并改变尺度

某个关节的位置误差为(2,2)像素,对象面积100,COCO式sigma为0.1。计算该关节的OKS项,再将所有坐标加倍、面积变为四倍。

答案: 平方距离是8,κ为0.2,分母2×100×0.2²也是8,所以结果为exp(−1),约0.367879。坐标加倍后平方距离为32,面积变400,指数不变。若漏掉κ=2σ,会错误地得到exp(−4)。

3. 诊断解码与匹配

在(1,2)、(5,2)设置两个等高峰,比较argmax与积分解码。再单独用两行为[0.9,0.8]、[0.8,0]的分数矩阵测试贪心关联。

答案: 本例按行展开的argmax选(1,2);积分解码得到(3,2),即使此处概率为零。两种结果都没有同时表达两个假设。贪心匹配先取0.9,留下零分边;精确部分匹配选择两条交叉边,总分1.6。解码歧义与分配冲突是两类不同错误。

4. 设计诚实的三维比较

一个模型利用完整视频片段,另一个在线运行,两篇论文报告了不同MPJPE。排名之前必须对齐哪些条件?

答案: 检查数据集划分、关节集合、输入二维检测还是二维真值、单位、根节点处理、尺度/旋转对齐,以及是否使用未来帧。条件不能对齐就分别报告。同时测量因果系统的延迟。在未来上下文和Procrustes对齐下误差更低,并不能证明绝对坐标在线跟踪更好。

沿着原始版本阅读方法变化

DeepPose的首个预印本提交于2013年12月17日;Stacked Hourglass为2016年3月22日;PAF为2016年11月24日;Integral Regression为2017年11月22日;VideoPose3D为2018年11月28日;HRNet为2019年2月25日。这些是稿件提交日期,不能与会议年份或软件发布日期互换。DeepPose记录、Hourglass记录、PAF记录、Integral记录、VideoPose3D记录、HRNet记录

先读表示,再看排行榜:预测什么、采用哪个参考系、怎样监督、如何解码和评测?接着改变例子中的条件,观察究竟是哪一环出错。本项目研究记录保留了论文版本以及固定MMPose/COCO源码的实际读取范围;数值测试检查原创算子,不证明上游模型的准确率。

先判断,再看解释

COCO可见性标记1,在本篇OKS中意味着什么?

选择一个答案

学习目标

  • 追踪关节坐标经过裁剪、热图解码与逆变换的全过程。
  • 对完整小CNN和积分坐标解码器求导。
  • 解释多人关联并验证全局匹配反例。
  • 区分OKS、PCK、MPJPE及三维结论所需证据。

先修与延伸

查看知识关联图 →

参考文献

  1. DeepPose: Human Pose Estimation via Deep Neural Networks
    Alexander Toshev; Christian Szegedy · 2013
  2. Stacked Hourglass Networks for Human Pose Estimation
    Alejandro Newell; Kaiyu Yang; Jia Deng · 2016
  3. Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
    Zhe Cao; Tomas Simon; Shih-En Wei; Yaser Sheikh · 2016
  4. Integral Human Pose Regression
    Xiao Sun; Bin Xiao; Fangyin Wei; Shuang Liang; Yichen Wei · 2017
  5. Deep High-Resolution Representation Learning for Human Pose Estimation
    Ke Sun; Bin Xiao; Dong Liu; Jingdong Wang · 2019
  6. 3D human pose estimation in video with temporal convolutions and semi-supervised training
    Dario Pavllo; Christoph Feichtenhofer; David Grangier; Michael Auli · 2018
  7. MMPose fixed MSRA heatmap codec
    OpenMMLab contributors · 2025
  8. MMPose fixed Gaussian heatmap targets
    OpenMMLab contributors · 2025
  9. MMPose fixed maximum decoding
    OpenMMLab contributors · 2025
  10. MMPose fixed keypoint evaluation functions
    OpenMMLab contributors · 2025
  11. MMPose fixed COCO keypoint constants
    OpenMMLab contributors · 2025
  12. COCO fixed keypoint annotation format
    COCO contributors · 2023
  13. COCO fixed keypoint evaluation definition
    COCO contributors · 2023
  14. COCO fixed keypoint evaluator
    COCO contributors · 2019
  15. DeepPose: Human Pose Estimation via Deep Neural Networks — submission history
    Alexander Toshev; Christian Szegedy · 2013
  16. Stacked Hourglass Networks for Human Pose Estimation — submission history
    Alejandro Newell; Kaiyu Yang; Jia Deng · 2016
  17. Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields — submission history
    Zhe Cao; Tomas Simon; Shih-En Wei; Yaser Sheikh · 2016
  18. Integral Human Pose Regression — submission history
    Xiao Sun; Bin Xiao; Fangyin Wei; Shuang Liang; Yichen Wei · 2017
  19. 3D human pose estimation in video with temporal convolutions and semi-supervised training — submission history
    Dario Pavllo; Christoph Feichtenhofer; David Grangier; Michael Auli · 2018
  20. Deep High-Resolution Representation Learning for Human Pose Estimation — submission history
    Ke Sun; Bin Xiao; Dong Liu; Jingdong Wang · 2019

版本1 · 编写状态: 已完成记录中的技术复核

查看技术检查记录(AI)

Codex · 2026-09-07 · Codex single-AI-author technical check: scoped original papers and fixed MMPose/COCO source reading, all small-CNN parameter/input finite differences, independent coordinate/matching/metric tests, complete bilingual comparison and measured diagram binding. Not human peer review or pretrained pose benchmark reproduction.

  • 十九项独立数值检查加四项完整双语/输出/元数据/图示检查;127CNN参数和36输入全部中心差分,三个温度积分梯度、穷举匹配、PAF/OKS/几何已知值和无效输入。
  • 逐节核对完整双语、八组公式、完整代码/输出、四组解释答案和二十项限定来源;保留遮挡/未标注区别、κ=2σ、真值/学习结果、目标argmax/预测质量、版本日期边界与三维投影歧义。

核对的来源位置:

相关主题

没有匹配结果,试试英文名或缩写。

已显示 0 条结果

将整个查询放入双引号,可按短语匹配。