Exemple #1
0
 def test_average_precision_real_data(self, ovule_label):
     label = ovule_label[64:128, 64:128, 64:128]
     ltb = LabelToAffinities((1, 2, 4, 6), aggregate_affinities=True)
     pred = ltb(label)
     label = torch.tensor(label.reshape((1, 1) + label.shape).astype('int64'))
     pred = torch.tensor(np.expand_dims(pred, 0))
     ap = BoundaryAveragePrecision()
     assert ap(pred, label) > 0.5
Exemple #2
0
    def test_label_to_boundary_with_ignore(self):
        size = 20
        label = _diagonal_label_volume(size, init=-1)

        transform = LabelToAffinities(offsets=(2, 4), ignore_index=-1, aggregate_affinities=True)
        result = transform(label)
        assert result.shape == (2,) + label.shape
        assert np.array_equal(np.unique(result), [-1, 0, 1])
Exemple #3
0
    def test_label_to_boundary_no_aggregate(self):
        size = 20
        label = _diagonal_label_volume(size)

        # this transform will produce 6 channels
        transform = LabelToAffinities(offsets=(2, 4), aggregate_affinities=False)
        result = transform(label)
        assert result.shape == (6,) + label.shape
        assert np.array_equal(np.unique(result), [0, 1])
Exemple #4
0
 def test_average_precision_real_data(self):
     l_file = 'resources/sample_patch.h5'
     with h5py.File(l_file, 'r') as f:
         label = f['big_label'][...]
         ltb = LabelToAffinities((1, 2, 4, 6), aggregate_affinities=True)
         pred = ltb(label)
         # don't compare instances smaller than 25K voxels
         ap = BoundaryAveragePrecision(min_instance_size=25000)
         assert ap(pred, label) > 0.5