def eval_prop_multiprocessing()

in wypr/utils/eval_prop.py [0:0]


def eval_prop_multiprocessing(pred_all, gt_all, ovthresh=0.25, get_iou_func=get_iou):
    """ Generic functions to compute precision/recall for object detection for multiple classes.
        Input:
            pred_all: map of {img_id: (classname, bbox)}
            gt_all:   map of {img_id: (classname, bbox)}
            ovthresh: scalar, iou threshold
        Output:
            rec: {classname: rec}
            ABO: {classname: prec_all}
    """
    pred = {}; gt = {} # map {classname: gt}
    for img_id in pred_all.keys():
        for classname, bbox in pred_all[img_id]:
            if classname not in pred: pred[classname] = {}
            if img_id not in pred[classname]:  pred[classname][img_id] = []
            if classname not in gt: gt[classname] = {}
            if img_id not in gt[classname]:  gt[classname][img_id] = []
            pred[classname][img_id].append(bbox)
    for img_id in gt_all.keys():
        for classname, bbox in gt_all[img_id]:
            if classname not in gt: gt[classname] = {}
            if img_id not in gt[classname]: gt[classname][img_id] = []
            gt[classname][img_id].append(bbox)

    rec = {}; ABO = {}
    p = Pool(processes=10)
    ret_values = p.map(eval_prop_cls_wrapper, [(pred[classname], gt[classname], ovthresh, get_iou_func) for classname in gt.keys() if classname in pred])
    p.close()
    for i, classname in enumerate(gt.keys()):
        if classname in pred:
            rec[classname], ABO[classname] = ret_values[i]
        else:
            rec[classname] = 0; ABO[classname] = 0
    
    return rec, ABO