PCK(Percentage of Correct Keypoints)指标及python代码实现
姿态估计任务中,常用的评价指标有AP值、PCK等。
PCK指标定义
PCK指标指正确检测的关键点所占百分比,其定义如下:
其中,Tk为阈值,dpi为第p个人第i个关键点预测值与ground-truth之间的欧氏距离,下面除的dp为第p个人的归一化因子。
PCK指标python实现代码如下
#hanlestudy@163.com
def PCK_metric(pred, gt, thr):
num_imgs, num_points, _ = pred.shape
results = np.full((num_imgs, num_points), 0, dtype=np.float32)
thrs = []
for i in range(num_imgs):
for j in range(num_points):
distance = cal_distance(pred[i, j, :], gt[i, j, :])
if distance <= thr:
results[i, j] = 1
thrs = np.array(thrs)
print('mean:', np.mean(thrs))
mean_points = np.mean(results, axis=0)
mean_all = np.mean(mean_points)
return mean_points, mean_all
版权声明:本文为StupidAutofan原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。