Exemple #1
0
def create_loss(output, truth):
    # return tf.reduce_mean(tf.square(output-truth))
    match = approx_match(output, truth)
    repulsion_loss = get_repulsion_loss(output)
    emd_loss = tf.reduce_mean(match_cost(output, truth, match))

    cost_p1_p2, _, cost_p2_p1, _ = nn_distance(output, truth)
    chamfer_loss = tf.reduce_mean(
        tf.reduce_sum(cost_p1_p2, -1) + tf.reduce_sum(cost_p2_p1, -1))
    return emd_loss, chamfer_loss, repulsion_loss
Exemple #2
0
def create_loss_local(output, truth, loss_type='emd'):
    # return tf.reduce_mean(tf.square(output-truth))
    output = tf.reshape(output,
                        [-1, output.get_shape()[2],
                         output.get_shape()[3]])
    truth = tf.reshape(truth, [-1, truth.get_shape()[2], truth.get_shape()[3]])
    if loss_type == 'emd':
        match = approx_match(output, truth)
        return tf.reduce_mean(match_cost(output, truth, match))
    else:
        cost_p1_p2, _, cost_p2_p1, _ = nn_distance(output, truth)
        return tf.reduce_mean(cost_p1_p2) + tf.reduce_mean(cost_p2_p1)
Exemple #3
0
def get_chamfer_loss_pcn(output, truth):
    cost_p1_p2, _, cost_p2_p1, _ = nn_distance(output, truth)
    cost_p1_p2 = tf.reduce_mean(tf.sqrt(cost_p1_p2))
    cost_p2_p1 = tf.reduce_mean(tf.sqrt(cost_p2_p1))
    return (cost_p1_p2 + cost_p2_p1) / 2
Exemple #4
0
def get_eval_chamfer_loss(output, truth):
    cost_p1_p2, _, cost_p2_p1, _ = nn_distance(output, truth)
    chamfer_loss = tf.reduce_sum(cost_p1_p2, -1) + tf.reduce_sum(
        cost_p2_p1, -1)
    return chamfer_loss
def chamfer_single_side(pcd1, pcd2):
    dist1, _, dist2, _ = tf_nndistance.nn_distance(pcd1, pcd2)
    mdist1 = tf.reduce_mean(dist1)
    return mdist1
def chamfer(pcd1, pcd2):
    dist1, _, dist2, _ = tf_nndistance.nn_distance(pcd1, pcd2)
    mdist1 = tf.reduce_mean(dist1)
    mdist2 = tf.reduce_mean(dist2)
    return mdist1 + mdist2