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)
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)
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)