MCPcopy
hub / github.com/TencentARC/Pixal3D / normal_angle

Function normal_angle

pixal3d/utils/loss_utils.py:83–92  ·  view source on GitHub ↗
(pred, gt)

Source from the content-addressed store, hash-verified

81
82
83def normal_angle(pred, gt):
84 pred = pred * 2.0 - 1.0
85 gt = gt * 2.0 - 1.0
86 norms = pred.norm(dim=-1) * gt.norm(dim=-1)
87 cos_sim = (pred * gt).sum(-1) / (norms + 1e-9)
88 cos_sim = torch.clamp(cos_sim, -1.0, 1.0)
89 ang = torch.rad2deg(torch.acos(cos_sim[norms > 1e-9])).mean()
90 if ang.isnan():
91 return -1
92 return ang

Callers

nothing calls this directly

Calls 2

sumMethod · 0.80
meanMethod · 0.80

Tested by

no test coverage detected