Pytorch3d中的倒角损失函数Chamfer Distance Loss的用法(pytorch3d.loss.chamfer_distance)

API文档在这里

源码在这里

之前看到的一个干货满满的Pytorch3D安装指导与简单例子的帖子在这里

 官方tutorials中提到的用法在下面这个代码块里面,前面后面东西都挺多的就把和chamfer_distance相关的摘到了这里

from pytorch3d.ops import sample_points_from_meshes
from pytorch3d.loss import (
    chamfer_distance, 
    mesh_edge_loss, 
    mesh_laplacian_smoothing, 
    mesh_normal_consistency,
)

# We sample 5k points from the surface of each mesh 
sample_trg = sample_points_from_meshes(trg_mesh, 5000)
sample_src = sample_points_from_meshes(new_src_mesh, 5000)

# We compare the two sets of pointclouds by computing (a) the chamfer loss
loss_chamfer, _ = chamfer_distance(sample_trg, sample_src)

你可能感兴趣的:(深度学习,人工智能)