Esempio n. 1
0
def earth_mover(pcd1, pcd2):
	"""Normalised Earth Mover Distance"""
	assert pcd1.shape[1] == pcd2.shape[1]  # has the same number of points
	num_points = tf.cast(pcd1.shape[1], tf.float32)
	match = tf_approxmatch.approx_match(pcd1, pcd2)
	cost = tf_approxmatch.match_cost(pcd1, pcd2, match)
	return tf.reduce_mean(cost / num_points)
Esempio n. 2
0
def earth_mover(pcd1, pcd2):
    # return 2
    assert pcd1.shape[1] == pcd2.shape[1]
    num_points = tf.cast(pcd1.shape[1], tf.float32)
    match = tf_approxmatch.approx_match(pcd1, pcd2)
    cost = tf_approxmatch.match_cost(pcd1, pcd2, match)
    return tf.reduce_mean(cost / num_points)
Esempio n. 3
0
            break
        namelist.append(line)
# eval_path
eval_path = '../result/result_shapenet_ply_out_smooth_pt2466/'

# Initialize session
# xyz1:dataset_points * 3, xyz2:query_points * 3
xyz1 = tf.placeholder(tf.float32, shape=(None, 3))
xyz2 = tf.placeholder(tf.float32, shape=(None, 3))
xyz3 = tf.expand_dims(xyz1, 0)
xyz4 = tf.expand_dims(xyz2, 0)
# chamfer distance
dist1, idx1, dist2, idx2 = tf_nndistance.nn_distance(xyz3, xyz4)
# earth mover distance, notice that emd_dist return the sum of all distance
match = tf_approxmatch.approx_match(xyz3, xyz4)
emd_dist = tf_approxmatch.match_cost(xyz3, xyz4, match)

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
config.allow_soft_placement = True
sess = tf.Session(config=config)
sess.run(tf.global_variables_initializer())

###
class_name = {
    '02828884': 'bench',
    '03001627': 'chair',
    '03636649': 'lamp',
    '03691459': 'speaker',
    '04090263': 'firearm',
    '04379243': 'table',
Esempio n. 4
0
def emd(pcd1, pcd2):
    assert pcd1.shape[1] == pcd2.shape[1]
    num_points = tf.cast(pcd1.shape[1], tf.float32)
    match = tf_approxmatch.approx_match(pcd1, pcd2)
    cost = tf_approxmatch.match_cost(pcd1, pcd2, match)
    return cost / num_points