-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
🚀 Feature
NOTE: Allow in the chamfer_distance() function from pytorch3d.loss.chamfer
to also output intermediate values of cham_x and cham_y in order to being able for instance to compute F-score metric.
pytorch3d/pytorch3d/loss/chamfer.py
Line 217 in b879047
cham_dist = cham_x + cham_y |
Motivation
It would be great to have this feature in order to directly infer the F-score from these cham_x and cham_y distributions since F-Score & Chamfer distance are two useful metrics in 3D reconstruction for instance.
Pitch
Adding this feature would allow to easily compute F-score metric, in a similar fashion way as @ThibaultGROUEIX did in one of his repo: https://github.com/ThibaultGROUEIX/ChamferDistancePytorch
import torch
def fscore(dist1, dist2, threshold=0.001):
"""
Calculates the F-score between two point clouds with the corresponding threshold value.
:param dist1: Batch, N-Points
:param dist2: Batch, N-Points
:param th: float
:return: fscore, precision, recall
"""
# NB : In this depo, dist1 and dist2 are squared pointcloud euclidean distances, so you should adapt the threshold accordingly.
precision_1 = torch.mean((dist1 < threshold).float(), dim=1)
precision_2 = torch.mean((dist2 < threshold).float(), dim=1)
fscore = 2 * precision_1 * precision_2 / (precision_1 + precision_2)
fscore[torch.isnan(fscore)] = 0
return fscore, precision_1, precision_2
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request