(predictions, annotations, return_dict)
return return_dict
Evaluate predicted_file and return mAP.
Evaluate predicted_file and return mAP.
Evaluate predicted_file and return mAP .
def keypoint_eval(predictions, annotations, return_dict):
    """Evaluate predicted_file and return mAP."""

    oks_all = np.zeros((0))
    oks_num = 0
    
    # Construct set to speed up id searching.
    prediction_id_set = set(predictions['image_ids'])

    # for every annotation in our test/validation set
    for image_id in annotations['image_ids']:
        # if the image in the predictions, then compute oks
        if image_id in prediction_id_set:
            oks = compute_oks(anno=annotations['annos'][image_id], \
                              predict=predictions['annos'][image_id]['keypoint_annos'], \
                              delta=annotations['delta'])
            # view pairs with max OKSs as match ones, add to oks_all
            oks_all = np.concatenate((oks_all, np.max(oks, axis=1)), axis=0)
            # accumulate total num by max(gtN,pN)
            oks_num += np.max(oks.shape)
        else:
            # otherwise report warning
            return_dict['warning'].append(image_id+' is not in the prediction JSON file.')
            # number of humen in ground truth annotations
            gt_n = len(annotations['annos'][image_id]['human_annos'].keys())
            # fill 0 in oks scores
            oks_all = np.concatenate((oks_all, np.zeros((gt_n))), axis=0)
            # accumulate total num by ground truth number
            oks_num += gt_n

    # compute mAP by APs under different oks thresholds
    average_precision = []
    for threshold in np.linspace(0.5, 0.95, 10):
        average_precision.append(np.sum(oks_all > threshold)/np.float32(oks_num))
    return_dict['score'] = np.mean(average_precision)

    return return_dict
def keypoint_eval ( predictions , annotations , return_dict ) : oks_all = np . zeros ( ( 0 ) ) oks_num = 0 # Construct set to speed up id searching. prediction_id_set = set ( predictions [ 'image_ids' ] ) # for every annotation in our test/validation set for image_id in annotations [ 'image_ids' ] : # if the image in the predictions, then compute oks if image_id in prediction_id_set : oks = compute_oks ( anno = annotations [ 'annos' ] [ image_id ] , predict = predictions [ 'annos' ] [ image_id ] [ 'keypoint_annos' ] , delta = annotations [ 'delta' ] ) # view pairs with max OKSs as match ones, add to oks_all oks_all = np . concatenate ( ( oks_all , np . max ( oks , axis = 1 ) ) , axis = 0 ) # accumulate total num by max(gtN,pN) oks_num += np . max ( oks . shape ) else : # otherwise report warning return_dict [ 'warning' ] . append ( image_id + ' is not in the prediction JSON file.' ) # number of humen in ground truth annotations gt_n = len ( annotations [ 'annos' ] [ image_id ] [ 'human_annos' ] . keys ( ) ) # fill 0 in oks scores oks_all = np . concatenate ( ( oks_all , np . zeros ( ( gt_n ) ) ) , axis = 0 ) # accumulate total num by ground truth number oks_num += gt_n # compute mAP by APs under different oks thresholds average_precision = [ ] for threshold in np . linspace ( 0.5 , 0.95 , 10 ) : average_precision . append ( np . sum ( oks_all > threshold ) / np . float32 ( oks_num ) ) return_dict [ 'score' ] = np . mean ( average_precision ) return return_dict