def get_target(self, sampling_results, gt_masks, rcnn_train_cfg):
     pos_proposals = [res.pos_bboxes for res in sampling_results]
     pos_assigned_gt_inds = [
         res.pos_assigned_gt_inds for res in sampling_results
     ]   # NOTE pos_assigned_gt_inds: gt start from index 0
     mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
                                gt_masks, rcnn_train_cfg)
     return mask_targets
 def get_target(self, sampling_result, gt_masks, rcnn_train_cfg):
     pos_proposals = [res.pos_bboxes for res in sampling_result]
     pos_assigned_gt_inds = [
         res.pos_assigned_gt_inds for res in sampling_result
     ]
     mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
                                gt_masks, rcnn_train_cfg)
     return mask_targets
Exemplo n.º 3
0
 def get_target(self, sampling_results, gt_masks, rcnn_train_cfg):
     # first get pos_proposals from rpn outputs.
     pos_proposals = [res.pos_bboxes for res in sampling_results]
     # proposals are assigned to gt according to their IoU overlaps.
     # here to get the gt id for each proposal
     pos_assigned_gt_inds = [
         res.pos_assigned_gt_inds for res in sampling_results
     ]
     mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
                                gt_masks, rcnn_train_cfg)
     return mask_targets
 def get_mask_target(self, sampling_results, gt_masks, rcnn_train_cfg):
     # pos_proposals = [res.pos_bboxes for res in sampling_results]
     # pos_assigned_gt_inds = [
     #     res.pos_assigned_gt_inds for res in sampling_results
     # ]
     # mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
     #                            gt_masks, rcnn_train_cfg)
     proposals = [res.bboxes for res in sampling_results]
     assigned_gt_inds = [res.inds for res in sampling_results]
     mask_targets = mask_target(proposals, assigned_gt_inds, gt_masks,
                                rcnn_train_cfg)
     mask_bg_targets = mask_bg_target(proposals, gt_masks, rcnn_train_cfg)
     return mask_targets, mask_bg_targets
 def get_ms_target(self, sampling_results, gt_masks, labels, rcnn_train_cfg,
                   mask_pred):
     pos_proposals = [res.pos_bboxes for res in sampling_results]
     pos_assigned_gt_inds = [
         res.pos_assigned_gt_inds for res in sampling_results
     ]
     mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
                                gt_masks, rcnn_train_cfg)
     if self.class_agnostic:
         iou_targets = self.mask_iou(mask_pred, mask_targets,
                                     torch.zeros_like(labels))
     else:
         iou_targets = self.mask_iou(mask_pred, mask_targets, labels)
     return mask_targets, iou_targets
Exemplo n.º 6
0
    def get_all_target(self, sampling_results, gt_mask, rcnn_train_cfg):
        proposals = [
            torch.cat(res.pos_bboxes, res.neg_bboxes[:res.pos_bboxes.size(0)])
            for res in sampling_results
        ]

        assigned_gt_inds = [
            torch.cat([
                res.pos_assigned_gt_inds,
                torch.full(res.pos_bboxes.size(0), -1)
            ]) for res in sampling_results
        ]
        mask_targets = mask_target(proposals, assigned_gt_inds, gt_mask,
                                   rcnn_train_cfg)

        return mask_targets
Exemplo n.º 7
0
    def get_target_mask(self, sampling_results, gt_masks, rcnn_train_cfg):
        # mix all samples (across images) together.
        pos_bboxes = torch.cat([res.pos_bboxes for res in sampling_results],
                               dim=0)
        pos_gt_bboxes = torch.cat(
            [res.pos_gt_bboxes for res in sampling_results], dim=0)

        assert pos_bboxes.shape == pos_gt_bboxes.shape

        pos_assigned_gt_inds = [
            res.pos_assigned_gt_inds for res in sampling_results
        ]
        instances = mask_target([res.pos_bboxes for res in sampling_results],
                                pos_assigned_gt_inds, gt_masks, rcnn_train_cfg)
        masks = F.interpolate(instances.unsqueeze(0),
                              scale_factor=1 / 4,
                              mode='bilinear',
                              align_corners=False).squeeze(0)
        masks = masks.gt(0.5).float()

        num_rois = pos_bboxes.shape[0]
        map_size = 7
        targets = pos_bboxes.new_zeros((num_rois, 4, map_size, map_size),
                                       dtype=torch.float)
        points = pos_bboxes.new_zeros((num_rois, 4, map_size, map_size),
                                      dtype=torch.float)

        for j in range(map_size):
            y = pos_bboxes[:, 1] + (pos_bboxes[:, 3] -
                                    pos_bboxes[:, 1]) / map_size * (j + 0.5)

            for i in range(map_size):
                x = pos_bboxes[:, 0] + (
                    pos_bboxes[:, 2] - pos_bboxes[:, 0]) / map_size * (i + 0.5)

                targets[:, 0, j, i] = x - pos_gt_bboxes[:, 0]
                targets[:, 1, j, i] = pos_gt_bboxes[:, 2] - x
                targets[:, 2, j, i] = y - pos_gt_bboxes[:, 1]
                targets[:, 3, j, i] = pos_gt_bboxes[:, 3] - y

                points[:, 0, j, i] = x
                points[:, 1, j, i] = y
                points[:, 2, j, i] = pos_bboxes[:, 2] - pos_bboxes[:, 0]
                points[:, 3, j, i] = pos_bboxes[:, 3] - pos_bboxes[:, 1]

        return points, targets, masks, instances
Exemplo n.º 8
0
 def get_mask_target(self, pos_proposals, pos_assigned_gt_inds, gt_masks,
                     rcnn_train_cfg):
     mask_targets = mask_target(pos_proposals, pos_assigned_gt_inds,
                                gt_masks, rcnn_train_cfg)
     return mask_targets
 def get_target(self, sampling_results, gt_masks, proto_cfg):
     proposals = [res.bboxes for res in sampling_results]
     assgined_gt_inds = [res.inds for res in sampling_results]
     all_target = mask_target(proposals, assgined_gt_inds, gt_masks,
                              proto_cfg)
     return all_target
Exemplo n.º 10
0
 def get_all_target(self, sampling_results, gt_mask, rcnn_train_cfg):
     proposals = [res.bboxes for res in sampling_results]
     assigned_gt_inds = [res.inds for res in sampling_results]
     all_target = mask_target(proposals, assigned_gt_inds, gt_mask,
                              rcnn_train_cfg)
     return all_target