(gt_hair_strands, pred_hair_strands)
| 18 | return loss_l1 |
| 19 | |
| 20 | def compute_loss_dir_dot(gt_hair_strands, pred_hair_strands): |
| 21 | nr_verts_per_strand=256 |
| 22 | |
| 23 | pred_points = pred_hair_strands.view(-1, nr_verts_per_strand, 3) |
| 24 | gt_hair_strands=gt_hair_strands.view(-1, nr_verts_per_strand, 3) |
| 25 | |
| 26 | # get also a loss for the direciton, we need to compute the direction |
| 27 | pred_deltas = compute_dirs(pred_points) |
| 28 | pred_deltas = pred_deltas.view(-1, 3) |
| 29 | pred_deltas = torch.nn.functional.normalize(pred_deltas, dim=-1) |
| 30 | |
| 31 | gt_dir = compute_dirs(gt_hair_strands) |
| 32 | gt_dir = gt_dir.view(-1, 3) |
| 33 | gt_dir = torch.nn.functional.normalize(gt_dir, dim=-1) |
| 34 | # loss_dir = self.cosine_embed_loss(pred_deltas, gt_dir, torch.ones(gt_dir.shape[0]).cuda()) |
| 35 | |
| 36 | dot = torch.sum(pred_deltas * gt_dir, dim=-1) |
| 37 | |
| 38 | loss_dir = (1.0 - dot).mean() |
| 39 | |
| 40 | return loss_dir |
| 41 | |
| 42 | def compute_loss_dir_l1(gt_hair_strands, pred_hair_strands): |
| 43 | nr_verts_per_strand=256 |
nothing calls this directly
no test coverage detected