(anno, predict, delta)
return oks
Compute oks matrix (size gtN*pN).
Compute oks matrix (size gtN*pN).
Compute oks matrix ( size gtN * pN ) .
def compute_oks(anno, predict, delta):
    """Compute oks matrix (size gtN*pN)."""

    anno_count = len(anno['keypoint_annos'].keys())
    predict_count = len(predict.keys())
    oks = np.zeros((anno_count, predict_count))
    if predict_count == 0:
        return oks.T

    # for every human keypoint annotation
    for i in range(anno_count):
        anno_key = anno['keypoint_annos'].keys()[i]
        anno_keypoints = np.reshape(anno['keypoint_annos'][anno_key], (14, 3))
        visible = anno_keypoints[:, 2] == 1
        bbox = anno['human_annos'][anno_key]
        scale = np.float32((bbox[3]-bbox[1])*(bbox[2]-bbox[0]))
        if np.sum(visible) == 0:
            for j in range(predict_count):
                oks[i, j] = 0
        else:
            # for every predicted human
            for j in range(predict_count):
                predict_key = predict.keys()[j]
                predict_keypoints = np.reshape(predict[predict_key], (14, 3))
                dis = np.sum((anno_keypoints[visible, :2] \
                    - predict_keypoints[visible, :2])**2, axis=1)
                oks[i, j] = np.mean(np.exp(-dis/2/delta[visible]**2/(scale+1)))
    return oks
def compute_oks ( anno , predict , delta ) : anno_count = len ( anno [ 'keypoint_annos' ] . keys ( ) ) predict_count = len ( predict . keys ( ) ) oks = np . zeros ( ( anno_count , predict_count ) ) if predict_count == 0 : return oks . T # for every human keypoint annotation for i in range ( anno_count ) : anno_key = anno [ 'keypoint_annos' ] . keys ( ) [ i ] anno_keypoints = np . reshape ( anno [ 'keypoint_annos' ] [ anno_key ] , ( 14 , 3 ) ) visible = anno_keypoints [ : , 2 ] == 1 bbox = anno [ 'human_annos' ] [ anno_key ] scale = np . float32 ( ( bbox [ 3 ] - bbox [ 1 ] ) * ( bbox [ 2 ] - bbox [ 0 ] ) ) if np . sum ( visible ) == 0 : for j in range ( predict_count ) : oks [ i , j ] = 0 else : # for every predicted human for j in range ( predict_count ) : predict_key = predict . keys ( ) [ j ] predict_keypoints = np . reshape ( predict [ predict_key ] , ( 14 , 3 ) ) dis = np . sum ( ( anno_keypoints [ visible , : 2 ] - predict_keypoints [ visible , : 2 ] ) ** 2 , axis = 1 ) oks [ i , j ] = np . mean ( np . exp ( - dis / 2 / delta [ visible ] ** 2 / ( scale + 1 ) ) ) return oks