(approx_list,
                    inside_flag_list,
                    square_list,
                    gt_bboxes_list,
                    img_metas,
                    approxs_per_octave,
                    cfg,
                    gt_bboxes_ignore_list=None,
                    sampling=True,
                    unmap_outputs=True)
return (bbox_anchors_list, bbox_gts_list, bbox_weights_list, num_total_pos,
            num_total_neg)
Compute guided anchoring targets.

    Args:
        approx_list (list[list]): Multi level approxs of each image.
        inside_flag_list (list[list]): Multi level inside flags of each image.
        square_list (list[list]): Multi level squares of each image.
        gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image.
        img_metas (list[dict]): Meta info of each image.
        approxs_per_octave (int): number of approxs per octave
        cfg (dict): RPN train configs.
        gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes.
        sampling (bool): sampling or not.
        unmap_outputs (bool): unmap outputs or not.

    Returns:
        tuple
Compute guided anchoring targets.
Compute guided anchoring targets .
def ga_shape_target(approx_list,
                    inside_flag_list,
                    square_list,
                    gt_bboxes_list,
                    img_metas,
                    approxs_per_octave,
                    cfg,
                    gt_bboxes_ignore_list=None,
                    sampling=True,
                    unmap_outputs=True):
    """Compute guided anchoring targets.

    Args:
        approx_list (list[list]): Multi level approxs of each image.
        inside_flag_list (list[list]): Multi level inside flags of each image.
        square_list (list[list]): Multi level squares of each image.
        gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image.
        img_metas (list[dict]): Meta info of each image.
        approxs_per_octave (int): number of approxs per octave
        cfg (dict): RPN train configs.
        gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes.
        sampling (bool): sampling or not.
        unmap_outputs (bool): unmap outputs or not.

    Returns:
        tuple
    """
    num_imgs = len(img_metas)
    assert len(approx_list) == len(inside_flag_list) == len(
        square_list) == num_imgs
    # anchor number of multi levels
    num_level_squares = [squares.size(0) for squares in square_list[0]]
    # concat all level anchors and flags to a single tensor
    inside_flag_flat_list = []
    approx_flat_list = []
    square_flat_list = []
    for i in range(num_imgs):
        assert len(square_list[i]) == len(inside_flag_list[i])
        inside_flag_flat_list.append(torch.cat(inside_flag_list[i]))
        approx_flat_list.append(torch.cat(approx_list[i]))
        square_flat_list.append(torch.cat(square_list[i]))

    # compute targets for each image
    if gt_bboxes_ignore_list is None:
        gt_bboxes_ignore_list = [None for _ in range(num_imgs)]
    (all_bbox_anchors, all_bbox_gts, all_bbox_weights, pos_inds_list,
     neg_inds_list) = multi_apply(ga_shape_target_single,
                                  approx_flat_list,
                                  inside_flag_flat_list,
                                  square_flat_list,
                                  gt_bboxes_list,
                                  gt_bboxes_ignore_list,
                                  img_metas,
                                  approxs_per_octave=approxs_per_octave,
                                  cfg=cfg,
                                  sampling=sampling,
                                  unmap_outputs=unmap_outputs)
    # no valid anchors
    if any([bbox_anchors is None for bbox_anchors in all_bbox_anchors]):
        return None
    # sampled anchors of all images
    num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list])
    num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list])
    # split targets to a list w.r.t. multiple levels
    bbox_anchors_list = images_to_levels(all_bbox_anchors, num_level_squares)
    bbox_gts_list = images_to_levels(all_bbox_gts, num_level_squares)
    bbox_weights_list = images_to_levels(all_bbox_weights, num_level_squares)
    return (bbox_anchors_list, bbox_gts_list, bbox_weights_list, num_total_pos,
            num_total_neg)
def ga_shape_target ( approx_list , inside_flag_list , square_list , gt_bboxes_list , img_metas , approxs_per_octave , cfg , gt_bboxes_ignore_list = None , sampling = True , unmap_outputs = True ) : num_imgs = len ( img_metas ) assert len ( approx_list ) == len ( inside_flag_list ) == len ( square_list ) == num_imgs # anchor number of multi levels num_level_squares = [ squares . size ( 0 ) for squares in square_list [ 0 ] ] # concat all level anchors and flags to a single tensor inside_flag_flat_list = [ ] approx_flat_list = [ ] square_flat_list = [ ] for i in range ( num_imgs ) : assert len ( square_list [ i ] ) == len ( inside_flag_list [ i ] ) inside_flag_flat_list . append ( torch . cat ( inside_flag_list [ i ] ) ) approx_flat_list . append ( torch . cat ( approx_list [ i ] ) ) square_flat_list . append ( torch . cat ( square_list [ i ] ) ) # compute targets for each image if gt_bboxes_ignore_list is None : gt_bboxes_ignore_list = [ None for _ in range ( num_imgs ) ] ( all_bbox_anchors , all_bbox_gts , all_bbox_weights , pos_inds_list , neg_inds_list ) = multi_apply ( ga_shape_target_single , approx_flat_list , inside_flag_flat_list , square_flat_list , gt_bboxes_list , gt_bboxes_ignore_list , img_metas , approxs_per_octave = approxs_per_octave , cfg = cfg , sampling = sampling , unmap_outputs = unmap_outputs ) # no valid anchors if any ( [ bbox_anchors is None for bbox_anchors in all_bbox_anchors ] ) : return None # sampled anchors of all images num_total_pos = sum ( [ max ( inds . numel ( ) , 1 ) for inds in pos_inds_list ] ) num_total_neg = sum ( [ max ( inds . numel ( ) , 1 ) for inds in neg_inds_list ] ) # split targets to a list w.r.t. multiple levels bbox_anchors_list = images_to_levels ( all_bbox_anchors , num_level_squares ) bbox_gts_list = images_to_levels ( all_bbox_gts , num_level_squares ) bbox_weights_list = images_to_levels ( all_bbox_weights , num_level_squares ) return ( bbox_anchors_list , bbox_gts_list , bbox_weights_list , num_total_pos , num_total_neg )