(self, max_overlaps)
return keep_inds, int(fg_rois_per_this_image)
Return sample of at most fg_fraction * num_rois foreground indicies, padding
        the remaining num_rois with background indicies. Foreground and background labels
        are determined based on max_overlaps and the thresholds fg_thresh, bg_thresh_hi,
        bg_thresh_lo.
        Returns:
            keep_inds (array): (num_rois,) sampled indicies of bboxes.
            fg_rois_per_this_image (int): number of fg rois sampled from the image.
Return sample of at most fg_fraction * num_rois foreground indicies, padding
        the remaining num_rois with background indicies. Foreground and background labels
        are determined based on max_overlaps and the thresholds fg_thresh, bg_thresh_hi,
        bg_thresh_lo.
        Returns:
            keep_inds (array): (num_rois,) sampled indicies of bboxes.
            fg_rois_per_this_image (int): number of fg rois sampled from the image.
Return sample of at most fg_fraction * num_rois foreground indicies padding the remaining num_rois with background indicies . Foreground and background labels are determined based on max_overlaps and the thresholds fg_thresh bg_thresh_hi bg_thresh_lo . Returns : keep_inds ( array ) : ( num_rois ) sampled indicies of bboxes . fg_rois_per_this_image ( int ) : number of fg rois sampled from the image .
def _sample_fg_bg(self, max_overlaps):
        """Return sample of at most fg_fraction * num_rois foreground indicies, padding
        the remaining num_rois with background indicies. Foreground and background labels
        are determined based on max_overlaps and the thresholds fg_thresh, bg_thresh_hi,
        bg_thresh_lo.
        Returns:
            keep_inds (array): (num_rois,) sampled indicies of bboxes.
            fg_rois_per_this_image (int): number of fg rois sampled from the image.
        """
        # Split proposals into foreground and background based on overlap
        fg_inds = np.where(max_overlaps >= self.fg_thresh)[0]
        fg_rois_per_image = np.round(self.fg_fraction * self.num_rois)

        # Guard against the case when an image has fewer than fg_rois_per_image foreground RoIs
        fg_rois_per_this_image = min(fg_rois_per_image, fg_inds.size)

        # Sample foreground regions without replacement
        if fg_inds.size > 0 and not self.deterministic:
            fg_inds = self.be.rng.choice(fg_inds, size=int(fg_rois_per_this_image), replace=False)
        elif fg_inds.size > 0:
            fg_inds = fg_inds[:fg_rois_per_this_image]

        # Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI)
        bg_inds = np.where((max_overlaps < self.bg_thresh_hi) &
                           (max_overlaps >= self.bg_thresh_lo))[0]

        # Compute number of background RoIs to take from this image (guarding
        # against there being fewer than desired)
        bg_rois_per_this_image = self.num_rois - fg_rois_per_this_image
        bg_rois_per_this_image = min(bg_rois_per_this_image, bg_inds.size)

        # Sample background regions without replacement
        if bg_inds.size > 0 and not self.deterministic:
            bg_inds = self.be.rng.choice(bg_inds, size=int(bg_rois_per_this_image), replace=False)
        elif bg_inds.size > 0:
            bg_inds = bg_inds[:bg_rois_per_this_image]

        # The indices that we're selecting (both fg and bg)
        keep_inds = np.append(fg_inds, bg_inds)
        return keep_inds, int(fg_rois_per_this_image)
def _sample_fg_bg ( self , max_overlaps ) : # Split proposals into foreground and background based on overlap fg_inds = np . where ( max_overlaps >= self . fg_thresh ) [ 0 ] fg_rois_per_image = np . round ( self . fg_fraction * self . num_rois ) # Guard against the case when an image has fewer than fg_rois_per_image foreground RoIs fg_rois_per_this_image = min ( fg_rois_per_image , fg_inds . size ) # Sample foreground regions without replacement if fg_inds . size > 0 and not self . deterministic : fg_inds = self . be . rng . choice ( fg_inds , size = int ( fg_rois_per_this_image ) , replace = False ) elif fg_inds . size > 0 : fg_inds = fg_inds [ : fg_rois_per_this_image ] # Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI) bg_inds = np . where ( ( max_overlaps < self . bg_thresh_hi ) & ( max_overlaps >= self . bg_thresh_lo ) ) [ 0 ] # Compute number of background RoIs to take from this image (guarding # against there being fewer than desired) bg_rois_per_this_image = self . num_rois - fg_rois_per_this_image bg_rois_per_this_image = min ( bg_rois_per_this_image , bg_inds . size ) # Sample background regions without replacement if bg_inds . size > 0 and not self . deterministic : bg_inds = self . be . rng . choice ( bg_inds , size = int ( bg_rois_per_this_image ) , replace = False ) elif bg_inds . size > 0 : bg_inds = bg_inds [ : bg_rois_per_this_image ] # The indices that we're selecting (both fg and bg) keep_inds = np . append ( fg_inds , bg_inds ) return keep_inds , int ( fg_rois_per_this_image )