Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
    def test_average_precision_synthethic_data(self):
        input = np.zeros((64, 200, 200), dtype=np.int)
        for i in range(40, 200, 40):
            input[:, :, i:i + 2] = 1
        for i in range(40, 200, 40):
            input[:, i:i + 2, :] = 1
        for i in range(40, 64, 40):
            input[i:i + 2, :, :] = 1

        target = measure.label(np.logical_not(input).astype(np.int), background=0)
        input = torch.tensor(input.reshape((1, 1) + input.shape))
        target = torch.tensor(target.reshape((1, 1) + target.shape))
        ap = BoundaryAveragePrecision()
        # expect perfect AP
        assert ap(input, target) == 1.0
Ejemplo n.º 4
0
    def test_average_precision_synthethic_data(self):
        input = np.zeros((64, 200, 200), dtype=np.int)
        for i in range(40, 200, 40):
            input[:, :, i:i + 2] = 1
        for i in range(40, 200, 40):
            input[:, i:i + 2, :] = 1
        for i in range(40, 64, 40):
            input[i:i + 2, :, :] = 1

        target = measure.label(np.logical_not(input).astype(np.int),
                               background=0)
        input = np.expand_dims(input, axis=0)
        ap = BoundaryAveragePrecision()
        # expect perfect AP
        assert ap(input, target) == 1.0