(det_bboxes, gt_bboxes, gt_ignore, iou_thr, area_ranges=None)
return tp, fp
Check if detected bboxes are true positive or false positive.

    Args:
        det_bbox (ndarray): the detected bbox
        gt_bboxes (ndarray): ground truth bboxes of this image
        gt_ignore (ndarray): indicate if gts are ignored for evaluation or not
        iou_thr (float): the iou thresholds

    Returns:
        tuple: (tp, fp), two arrays whose elements are 0 and 1
Check if detected bboxes are true positive or false positive.
Check if detected bboxes are true positive or false positive .
def tpfp_default(det_bboxes, gt_bboxes, gt_ignore, iou_thr, area_ranges=None):
    """Check if detected bboxes are true positive or false positive.

    Args:
        det_bbox (ndarray): the detected bbox
        gt_bboxes (ndarray): ground truth bboxes of this image
        gt_ignore (ndarray): indicate if gts are ignored for evaluation or not
        iou_thr (float): the iou thresholds

    Returns:
        tuple: (tp, fp), two arrays whose elements are 0 and 1
    """
    num_dets = det_bboxes.shape[0]
    num_gts = gt_bboxes.shape[0]
    if area_ranges is None:
        area_ranges = [(None, None)]
    num_scales = len(area_ranges)
    # tp and fp are of shape (num_scales, num_gts), each row is tp or fp of
    # a certain scale
    tp = np.zeros((num_scales, num_dets), dtype=np.float32)
    fp = np.zeros((num_scales, num_dets), dtype=np.float32)
    # if there is no gt bboxes in this image, then all det bboxes
    # within area range are false positives
    if gt_bboxes.shape[0] == 0:
        if area_ranges == [(None, None)]:
            fp[...] = 1
        else:
            det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * (
                det_bboxes[:, 3] - det_bboxes[:, 1] + 1)
            for i, (min_area, max_area) in enumerate(area_ranges):
                fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1
        return tp, fp
    ious = bbox_overlaps(det_bboxes, gt_bboxes)
    ious_max = ious.max(axis=1)
    ious_argmax = ious.argmax(axis=1)
    sort_inds = np.argsort(-det_bboxes[:, -1])
    for k, (min_area, max_area) in enumerate(area_ranges):
        gt_covered = np.zeros(num_gts, dtype=bool)
        # if no area range is specified, gt_area_ignore is all False
        if min_area is None:
            gt_area_ignore = np.zeros_like(gt_ignore, dtype=bool)
        else:
            gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * (
                gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1)
            gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area)
        for i in sort_inds:
            if ious_max[i] >= iou_thr:
                matched_gt = ious_argmax[i]
                if not (gt_ignore[matched_gt] or gt_area_ignore[matched_gt]):
                    if not gt_covered[matched_gt]:
                        gt_covered[matched_gt] = True
                        tp[k, i] = 1
                    else:
                        fp[k, i] = 1
                # otherwise ignore this detected bbox, tp = 0, fp = 0
            elif min_area is None:
                fp[k, i] = 1
            else:
                bbox = det_bboxes[i, :4]
                area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1)
                if area >= min_area and area < max_area:
                    fp[k, i] = 1
    return tp, fp
def tpfp_default ( det_bboxes , gt_bboxes , gt_ignore , iou_thr , area_ranges = None ) : num_dets = det_bboxes . shape [ 0 ] num_gts = gt_bboxes . shape [ 0 ] if area_ranges is None : area_ranges = [ ( None , None ) ] num_scales = len ( area_ranges ) # tp and fp are of shape (num_scales, num_gts), each row is tp or fp of # a certain scale tp = np . zeros ( ( num_scales , num_dets ) , dtype = np . float32 ) fp = np . zeros ( ( num_scales , num_dets ) , dtype = np . float32 ) # if there is no gt bboxes in this image, then all det bboxes # within area range are false positives if gt_bboxes . shape [ 0 ] == 0 : if area_ranges == [ ( None , None ) ] : fp [ ... ] = 1 else : det_areas = ( det_bboxes [ : , 2 ] - det_bboxes [ : , 0 ] + 1 ) * ( det_bboxes [ : , 3 ] - det_bboxes [ : , 1 ] + 1 ) for i , ( min_area , max_area ) in enumerate ( area_ranges ) : fp [ i , ( det_areas >= min_area ) & ( det_areas < max_area ) ] = 1 return tp , fp ious = bbox_overlaps ( det_bboxes , gt_bboxes ) ious_max = ious . max ( axis = 1 ) ious_argmax = ious . argmax ( axis = 1 ) sort_inds = np . argsort ( - det_bboxes [ : , - 1 ] ) for k , ( min_area , max_area ) in enumerate ( area_ranges ) : gt_covered = np . zeros ( num_gts , dtype = bool ) # if no area range is specified, gt_area_ignore is all False if min_area is None : gt_area_ignore = np . zeros_like ( gt_ignore , dtype = bool ) else : gt_areas = ( gt_bboxes [ : , 2 ] - gt_bboxes [ : , 0 ] + 1 ) * ( gt_bboxes [ : , 3 ] - gt_bboxes [ : , 1 ] + 1 ) gt_area_ignore = ( gt_areas < min_area ) | ( gt_areas >= max_area ) for i in sort_inds : if ious_max [ i ] >= iou_thr : matched_gt = ious_argmax [ i ] if not ( gt_ignore [ matched_gt ] or gt_area_ignore [ matched_gt ] ) : if not gt_covered [ matched_gt ] : gt_covered [ matched_gt ] = True tp [ k , i ] = 1 else : fp [ k , i ] = 1 # otherwise ignore this detected bbox, tp = 0, fp = 0 elif min_area is None : fp [ k , i ] = 1 else : bbox = det_bboxes [ i , : 4 ] area = ( bbox [ 2 ] - bbox [ 0 ] + 1 ) * ( bbox [ 3 ] - bbox [ 1 ] + 1 ) if area >= min_area and area < max_area : fp [ k , i ] = 1 return tp , fp