MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / compute_loss_curv_l1

Function compute_loss_curv_l1

losses/losses.py:61–80  ·  view source on GitHub ↗
(gt_hair_strands, pred_hair_strands)

Source from the content-addressed store, hash-verified

59 return loss_l1
60
61def compute_loss_curv_l1(gt_hair_strands, pred_hair_strands):
62 nr_verts_per_strand=256
63
64 pred_points = pred_hair_strands.view(-1, nr_verts_per_strand, 3)
65 gt_hair_strands=gt_hair_strands.view(-1, nr_verts_per_strand, 3)
66
67 # get also a loss for the direciton, we need to compute the direction
68 pred_deltas = compute_dirs(pred_points)
69 pred_curvs = compute_curv(pred_deltas)
70 pred_curvs = pred_curvs.view(-1, 3)
71 pred_curvs = pred_curvs*nr_verts_per_strand #Just because the deltas are very tiny and I want them in a nicer range for the loss
72
73 gt_dir = compute_dirs(gt_hair_strands)
74 gt_curvs = compute_curv(gt_dir)
75 gt_curvs = gt_curvs.view(-1, 3)
76 gt_curvs = gt_curvs*nr_verts_per_strand #Just because the deltas are very tiny and I want them in a nicer range for the loss
77 # loss_dir = self.cosine_embed_loss(pred_deltas, gt_dir, torch.ones(gt_dir.shape[0]).cuda())
78
79 loss_l1 = torch.nn.functional.l1_loss(pred_curvs, gt_curvs).mean()
80 return loss_l1
81
82def compute_loss_kl(mean, logstd):
83 #get input data

Callers 1

forwardMethod · 0.90

Calls 2

compute_dirsFunction · 0.90
compute_curvFunction · 0.90

Tested by

no test coverage detected