(self, proposals, targets)
return proposals
This method performs the positive/negative sampling, and return
        the sampled proposals.
        Note: this function keeps a state.

        Arguments:
            proposals (list[BoxList])
            targets (list[BoxList])
This method performs the positive/negative sampling, and return
        the sampled proposals.
        Note: this function keeps a state.
This method performs the positive / negative sampling and return the sampled proposals . Note : this function keeps a state .
def subsample(self, proposals, targets):
        """
        This method performs the positive/negative sampling, and return
        the sampled proposals.
        Note: this function keeps a state.

        Arguments:
            proposals (list[BoxList])
            targets (list[BoxList])
        """

        labels, kes, mty = self.prepare_targets(proposals, targets)
        sampled_pos_inds, sampled_neg_inds = self.fg_bg_sampler(labels)

        proposals = list(proposals)
        # add corresponding label and regression_targets information to the bounding boxes
        for labels_per_image, kes_per_image, mty_per_image, proposals_per_image in zip(
            labels, kes, mty, proposals
        ):
            proposals_per_image.add_field("labels", labels_per_image)
            proposals_per_image.add_field("kes", kes_per_image)
            proposals_per_image.add_field("mty", mty_per_image)

        # distributed sampled proposals, that were obtained on all feature maps
        # concatenated via the fg_bg_sampler, into individual feature map levels
        for img_idx, (pos_inds_img, neg_inds_img) in enumerate(
            zip(sampled_pos_inds, sampled_neg_inds)
        ):
            # img_sampled_inds = torch.nonzero(pos_inds_img | neg_inds_img).squeeze(1)
            img_sampled_inds = torch.nonzero(pos_inds_img).squeeze(1)
            proposals_per_image = proposals[img_idx][img_sampled_inds]
            proposals[img_idx] = proposals_per_image

        self._proposals = proposals
        return proposals
def subsample ( self , proposals , targets ) : labels , kes , mty = self . prepare_targets ( proposals , targets ) sampled_pos_inds , sampled_neg_inds = self . fg_bg_sampler ( labels ) proposals = list ( proposals ) # add corresponding label and regression_targets information to the bounding boxes for labels_per_image , kes_per_image , mty_per_image , proposals_per_image in zip ( labels , kes , mty , proposals ) : proposals_per_image . add_field ( "labels" , labels_per_image ) proposals_per_image . add_field ( "kes" , kes_per_image ) proposals_per_image . add_field ( "mty" , mty_per_image ) # distributed sampled proposals, that were obtained on all feature maps # concatenated via the fg_bg_sampler, into individual feature map levels for img_idx , ( pos_inds_img , neg_inds_img ) in enumerate ( zip ( sampled_pos_inds , sampled_neg_inds ) ) : # img_sampled_inds = torch.nonzero(pos_inds_img | neg_inds_img).squeeze(1) img_sampled_inds = torch . nonzero ( pos_inds_img ) . squeeze ( 1 ) proposals_per_image = proposals [ img_idx ] [ img_sampled_inds ] proposals [ img_idx ] = proposals_per_image self . _proposals = proposals return proposals