Esempio n. 1
0
 def test_chamfer_is_better_after_fit(self):
     d = load_test_files()
     dist_orig = metrics.chamfer_distance(d[0], d[1], scale=0.1)
     vg_fit = fit.icp(d[1], d[0], scale=0.1)
     dist_fit = metrics.chamfer_distance(d[0], vg_fit, scale=0.1)
     self.assertLess(dist_fit, dist_orig,
                     "Distance was not lower after fitting with icp")
Esempio n. 2
0
 def test_chamfer_distance_voxelgrid_on_simple(self):
     vg1 = tf.cast([[[0, 0, 0], [0, 1, 0], [0, 1, 0]],
                    [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
                    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]], tf.float32)
     vg2 = tf.cast([[[0, 0, 0], [0, 1, 0], [0, 0, 0]],
                    [[0, 0, 0], [0, 1, 0], [0, 0, 0]],
                    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]], tf.float32)
     d = (0.0 + 1)/2 + (0.0 + 1)/2
     self.assertEqual(d, metrics.chamfer_distance(vg1, vg2, scale=1.0))
     self.assertEqual(d/4, metrics.chamfer_distance(vg1, vg2, scale=1.0/4))
Esempio n. 3
0
def run_inference(elem):
    if ARGS.enforce_contact:
        return wip_enforce_contact(elem)

    if ARGS.publish_closest_train:
        # Computes and publishes the closest element in the training set to the test shape
        train_in_correct_augmentation = train_records.filter(lambda x: x['augmentation'] == elem['augmentation'][0])
        train_in_correct_augmentation = shape_completion_training.utils.old_dataset_tools.load_voxelgrids(train_in_correct_augmentation)
        min_cd = np.inf
        closest_train = None
        for train_elem in train_in_correct_augmentation:
            VG_PUB.publish("plausible", train_elem['gt_occ'])
            cd = chamfer_distance(elem['gt_occ'], train_elem['gt_occ'],
                                  scale=0.01, downsample=4)
            if cd < min_cd:
                min_cd = cd
                closest_train = train_elem['gt_occ']
            VG_PUB.publish("plausible", closest_train)

    # raw_input("Ready to display best?")

    inference = model_runner.model(elem)
    VG_PUB.publish_inference(inference)

    return inference
Esempio n. 4
0
 def test_chamfer_distance_voxelgrid_on_real(self):
     d = load_test_files()
     self.assertEqual(0.0, metrics.chamfer_distance(d[0], d[0], scale=0.1))
     self.assertGreater(metrics.chamfer_distance(d[0], d[1], scale=0.1),
                        0.0)
Esempio n. 5
0
 def m(vg1, vg2):
     vg_fit = fit.icp(vg2, vg1, scale=0.1, max_iter=10, downsample=2)
     return metrics.chamfer_distance(vg1,
                                     vg_fit,
                                     scale=0.1,
                                     downsample=2)
def vg_chamfer_distance(vg1, vg2, scale):
    return chamfer_distance(vg1, vg2, scale, downsample=3)