(rois, overlaps, labels, seg, class_id)
return mask_targets, mask_label, ex_inds
given rois, overlaps, gt labels, seg, compute bounding box mask targets
    :param rois: roidb[i]['boxes'] k * 4
    :param overlaps: roidb[i]['max_overlaps'] k * 1
    :param labels: roidb[i]['max_classes'] k * 1
    :return: targets[i][class, dx, dy, dw, dh] k * 5
given rois, overlaps, gt labels, seg, compute bounding box mask targets
    :param rois: roidb[i]['boxes'] k * 4
    :param overlaps: roidb[i]['max_overlaps'] k * 1
    :param labels: roidb[i]['max_classes'] k * 1
    :return: targets[i][class, dx, dy, dw, dh] k * 5
given rois overlaps gt labels seg compute bounding box mask targets : param rois : roidb [ i ] [ boxes ] k * 4 : param overlaps : roidb [ i ] [ max_overlaps ] k * 1 : param labels : roidb [ i ] [ max_classes ] k * 1 : return : targets [ i ] [ class dx dy dw dh ] k * 5
def compute_bbox_mask_targets_and_label(rois, overlaps, labels, seg, class_id):
    """
    given rois, overlaps, gt labels, seg, compute bounding box mask targets
    :param rois: roidb[i]['boxes'] k * 4
    :param overlaps: roidb[i]['max_overlaps'] k * 1
    :param labels: roidb[i]['max_classes'] k * 1
    :return: targets[i][class, dx, dy, dw, dh] k * 5
    """
    # Ensure ROIs are floats
    rois = rois.astype(np.float, copy=False)

    # Sanity check
    if len(rois) != len(overlaps):
        print('bbox regression: this should not happen')

    # Indices of ground-truth ROIs
    gt_inds = np.where(overlaps == 1)[0]
    if len(gt_inds) == 0:
        print('something wrong : zero ground truth rois')
    # Indices of examples for which we try to make predictions
    ex_inds = np.where(overlaps >= config.train.bbox_regression_thresh)[0]

    # Get IoU overlap between each ex ROI and gt ROI
    ex_gt_overlaps = bbox_overlaps(rois[ex_inds, :], rois[gt_inds, :])


    # Find which gt ROI each ex ROI has max overlap with:
    # this will be the ex ROI's gt target
    gt_assignment = ex_gt_overlaps.argmax(axis=1)
    gt_rois = rois[gt_inds[gt_assignment], :]
    ex_rois = rois[ex_inds, :]

    mask_targets, mask_label = compute_mask_and_label(ex_rois, labels[ex_inds], seg, class_id)
    return mask_targets, mask_label, ex_inds
def compute_bbox_mask_targets_and_label ( rois , overlaps , labels , seg , class_id ) : # Ensure ROIs are floats rois = rois . astype ( np . float , copy = False ) # Sanity check if len ( rois ) != len ( overlaps ) : print ( 'bbox regression: this should not happen' ) # Indices of ground-truth ROIs gt_inds = np . where ( overlaps == 1 ) [ 0 ] if len ( gt_inds ) == 0 : print ( 'something wrong : zero ground truth rois' ) # Indices of examples for which we try to make predictions ex_inds = np . where ( overlaps >= config . train . bbox_regression_thresh ) [ 0 ] # Get IoU overlap between each ex ROI and gt ROI ex_gt_overlaps = bbox_overlaps ( rois [ ex_inds , : ] , rois [ gt_inds , : ] ) # Find which gt ROI each ex ROI has max overlap with: # this will be the ex ROI's gt target gt_assignment = ex_gt_overlaps . argmax ( axis = 1 ) gt_rois = rois [ gt_inds [ gt_assignment ] , : ] ex_rois = rois [ ex_inds , : ] mask_targets , mask_label = compute_mask_and_label ( ex_rois , labels [ ex_inds ] , seg , class_id ) return mask_targets , mask_label , ex_inds