コード例 #1
0
 def test_finalise(self):
     tracker = SegmentationTracker(MockDataset(), ignore_label=-100)
     tracker.reset("test")
     model = MockModel()
     model.iter = 3
     tracker.track(model)
     tracker.finalise()
     with self.assertRaises(RuntimeError):
         tracker.track(model)
コード例 #2
0
 def test_ignore_label(self):
     tracker = SegmentationTracker(MockDataset(), ignore_label=-100)
     tracker.reset("test")
     model = MockModel()
     model.iter = 3
     tracker.track(model)
     metrics = tracker.get_metrics()
     for k in ["test_acc", "test_miou", "test_macc"]:
         self.assertAlmostEqual(metrics[k], 100, 5)
コード例 #3
0
    def test_track(self):
        tracker = SegmentationTracker(MockDataset())
        model = MockModel()
        tracker.track(model)
        metrics = tracker.get_metrics()
        for k in ["train_acc", "train_miou", "train_macc"]:
            self.assertAlmostEqual(metrics[k], 100, 5)

        model.iter += 1
        tracker.track(model)
        metrics = tracker.get_metrics()
        for k in ["train_acc", "train_macc"]:
            self.assertEqual(metrics[k], 50)
        self.assertAlmostEqual(metrics["train_miou"], 25, 5)
        self.assertEqual(metrics["train_loss_1"], 1.5)

        tracker.reset("test")
        model.iter += 1
        tracker.track(model)
        metrics = tracker.get_metrics()
        for k in ["test_acc", "test_miou", "test_macc"]:
            self.assertAlmostEqual(metrics[k], 0, 5)