예제 #1
0
    def finalise(self,
                 full_res=False,
                 vote_miou=True,
                 ply_output="",
                 **kwargs):
        per_class_iou = self._confusion_matrix.get_intersection_union_per_class(
        )[0]
        self._iou_per_class = {
            self._dataset.INV_OBJECT_LABEL[k]: v
            for k, v in enumerate(per_class_iou)
        }

        if vote_miou and self._test_area:
            # Complete for points that have a prediction
            self._test_area = self._test_area.to("cpu")
            c = ConfusionMatrix(self._num_classes)
            has_prediction = self._test_area.prediction_count > 0
            gt = self._test_area.y[has_prediction].numpy()
            pred = torch.argmax(self._test_area.votes[has_prediction],
                                1).numpy()
            c.count_predicted_batch(gt, pred)
            self._vote_miou = c.get_average_intersection_union() * 100

        if full_res:
            self._compute_full_miou()

        if ply_output:
            has_prediction = self._test_area.prediction_count > 0
            self._dataset.to_ply(
                self._test_area.pos[has_prediction].cpu(),
                torch.argmax(self._test_area.votes[has_prediction],
                             1).cpu().numpy(),
                ply_output,
            )
예제 #2
0
    def _compute_full_miou(self):
        if self._full_vote_miou is not None:
            return

        has_prediction = self._test_area.prediction_count > 0
        log.info(
            "Computing full res mIoU, we have predictions for %.2f%% of the points."
            % (torch.sum(has_prediction) /
               (1.0 * has_prediction.shape[0]) * 100))

        self._test_area = self._test_area.to("cpu")

        # Full res interpolation
        full_pred = knn_interpolate(
            self._test_area.votes[has_prediction],
            self._test_area.pos[has_prediction],
            self._test_area.pos,
            k=1,
        )

        # Full res pred
        c = ConfusionMatrix(self._num_classes)
        c.count_predicted_batch(self._test_area.y.numpy(),
                                torch.argmax(full_pred, 1).numpy())
        self._full_vote_miou = c.get_average_intersection_union() * 100
예제 #3
0
 def reset(self, stage="train"):
     super().reset(stage=stage)
     self._confusion_matrix = ConfusionMatrix(self._num_classes)
     self._acc = 0
     self._macc = 0
     self._miou = 0
     self._miou_per_class = {}
예제 #4
0
 def reset(self, stage="train"):
     super().reset(stage=stage)
     self._full_confusion_matrix = ConfusionMatrix(self._num_classes)
     self._raw_datas = {}
     self._votes = {}
     self._vote_counts = {}
     self._full_preds = {}
     self._full_acc = None
예제 #5
0
 def reset(self, stage="train"):
     super().reset(stage=stage)
     self._confusion_matrix = ConfusionMatrix(self._num_classes)
     self._ap_meter = APMeter()