def _distribute_rois_over_fpn_levels(rois_blob_name): """Distribute rois over the different FPN levels.""" # Get target level for each roi # Recall blob rois are in (batch_idx, x1, y1, x2, y2) format, hence take # the box coordinates from columns 1:5 target_lvls = fpn.map_rois_to_fpn_levels(blobs[rois_blob_name][:, 1:5], lvl_min, lvl_max) # Add per FPN level roi blobs named like: <rois_blob_name>_fpn<lvl> fpn.add_multilevel_roi_blobs(blobs, rois_blob_name, blobs[rois_blob_name], target_lvls, lvl_min, lvl_max)
def _distribute_rois_over_fpn_levels(rois_blob_name): """Distribute rois over the different FPN levels.""" # Get target level for each roi # Recall blob rois are in (batch_idx, x1, y1, x2, y2) format, hence take # the box coordinates from columns 1:5 target_lvls = fpn.map_rois_to_fpn_levels( blobs[rois_blob_name][:, 1:5], lvl_min, lvl_max ) # Add per FPN level roi blobs named like: <rois_blob_name>_fpn<lvl> fpn.add_multilevel_roi_blobs( blobs, rois_blob_name, blobs[rois_blob_name], target_lvls, lvl_min, lvl_max )
def _add_multilevel_rois(blobs): """By default training RoIs are added for a single feature map level only. When using FPN, the RoIs must be distributed over different FPN levels according the level assignment heuristic (see: modeling.FPN. map_rois_to_fpn_levels). """ lvl_min = cfg.FPN.ROI_MIN_LEVEL lvl_max = cfg.FPN.ROI_MAX_LEVEL rois_blob_name = 'mask_rois' """Distribute rois over the different FPN levels.""" # Get target level for each roi # Recall blob rois are in (batch_idx, x1, y1, x2, y2) format, hence take # the box coordinates from columns 1:5 target_lvls = fpn.map_rois_to_fpn_levels(blobs[rois_blob_name][:, 1:5], lvl_min, lvl_max) # Add per FPN level roi blobs named like: <rois_blob_name>_fpn<lvl> fpn.add_multilevel_roi_blobs(blobs, rois_blob_name, blobs[rois_blob_name], target_lvls, lvl_min, lvl_max)
def _add_multilevel_rois_for_test(blobs, name): """Distributes a set of RoIs across FPN pyramid levels by creating new level specific RoI blobs. Arguments: blobs (dict): dictionary of blobs name (str): a key in 'blobs' identifying the source RoI blob Returns: [by ref] blobs (dict): new keys named by `name + 'fpn' + level` are added to dict each with a value that's an R_level x 5 ndarray of RoIs (see _get_rois_blob for format) """ lvl_min = cfg.FPN.ROI_MIN_LEVEL lvl_max = cfg.FPN.ROI_MAX_LEVEL lvls = fpn.map_rois_to_fpn_levels(blobs[name][:, 1:5], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs(blobs, name, blobs[name], lvls, lvl_min, lvl_max)
def _add_multilevel_rois_for_test(blobs, name): """Distributes a set of RoIs across FPN pyramid levels by creating new level specific RoI blobs. Arguments: blobs (dict): dictionary of blobs name (str): a key in 'blobs' identifying the source RoI blob Returns: [by ref] blobs (dict): new keys named by `name + 'fpn' + level` are added to dict each with a value that's an R_level x 5 ndarray of RoIs (see _get_rois_blob for format) """ lvl_min = cfg.FPN.ROI_MIN_LEVEL lvl_max = cfg.FPN.ROI_MAX_LEVEL lvls = fpn.map_rois_to_fpn_levels(blobs[name][:, 1:], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs( blobs, name, blobs[name], lvls, lvl_min, lvl_max)
def _add_multilevel_rois(blobs): lvl_min = cfg.FPN.ROI_MIN_LEVEL lvl_max = cfg.FPN.ROI_MAX_LEVEL # The map_rois_to_fpn_levels and add_multilevel_roi_blobs functions are # shared among the 2D and 3D models. lvls = fpn.map_rois_to_fpn_levels(blobs['rois'][:, 1:], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs(blobs, 'rois', blobs['rois'], lvls, lvl_min, lvl_max) if cfg.MODEL.MASK_ON: # Masks use the same rois as the box/cls head fpn.add_multilevel_roi_blobs(blobs, 'mask_rois', blobs['rois'], lvls, lvl_min, lvl_max, valid_levels=blobs['roi_has_mask_int32']) if cfg.MODEL.KEYPOINTS_ON: # Keypoints use a separate set of training rois lvls = fpn.map_rois_to_fpn_levels(blobs['keypoint_rois'][:, 1:], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs(blobs, 'keypoint_rois', blobs['keypoint_rois'], lvls, lvl_min, lvl_max)
def _add_multilevel_rois(blobs): lvl_min = cfg.FPN.ROI_MIN_LEVEL lvl_max = cfg.FPN.ROI_MAX_LEVEL # The map_rois_to_fpn_levels and add_multilevel_roi_blobs functions are # shared among the 2D and 3D models. lvls = fpn.map_rois_to_fpn_levels(blobs['rois'][:, 1:], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs( blobs, 'rois', blobs['rois'], lvls, lvl_min, lvl_max) if cfg.MODEL.MASK_ON: # Masks use the same rois as the box/cls head fpn.add_multilevel_roi_blobs( blobs, 'mask_rois', blobs['rois'], lvls, lvl_min, lvl_max, valid_levels=blobs['roi_has_mask_int32']) if cfg.MODEL.KEYPOINTS_ON: # Keypoints use a separate set of training rois lvls = fpn.map_rois_to_fpn_levels( blobs['keypoint_rois'][:, 1:], lvl_min, lvl_max) fpn.add_multilevel_roi_blobs( blobs, 'keypoint_rois', blobs['keypoint_rois'], lvls, lvl_min, lvl_max)