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

Function compute_loss_dir_l1

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

Source from the content-addressed store, hash-verified

40 return loss_dir
41
42def compute_loss_dir_l1(gt_hair_strands, pred_hair_strands):
43 nr_verts_per_strand=256
44
45 pred_points = pred_hair_strands.view(-1, nr_verts_per_strand, 3)
46 gt_hair_strands=gt_hair_strands.view(-1, nr_verts_per_strand, 3)
47
48 # get also a loss for the direciton, we need to compute the direction
49 pred_deltas = compute_dirs(pred_points)
50 pred_deltas = pred_deltas.view(-1, 3)
51 pred_deltas = pred_deltas*nr_verts_per_strand #Just because the deltas are very tiny and I want them in a nicer range for the loss
52
53 gt_dir = compute_dirs(gt_hair_strands)
54 gt_dir = gt_dir.view(-1, 3)
55 gt_dir = gt_dir*nr_verts_per_strand #Just because the deltas are very tiny and I want them in a nicer range for the loss
56 # loss_dir = self.cosine_embed_loss(pred_deltas, gt_dir, torch.ones(gt_dir.shape[0]).cuda())
57
58 loss_l1 = torch.nn.functional.l1_loss(pred_deltas, gt_dir).mean()
59 return loss_l1
60
61def compute_loss_curv_l1(gt_hair_strands, pred_hair_strands):
62 nr_verts_per_strand=256

Callers 1

forwardMethod · 0.90

Calls 1

compute_dirsFunction · 0.90

Tested by

no test coverage detected