compute LP-IoU over two set of patches. Args: gen_patches (torch.Tensor): patches from generated shape ref_patches (torch.Tensor): patches from reference shape threshold (float, optional): IoU threshold. Defaults to 0.95. Returns: average max IoU, LP-IoU
(gen_patches: torch.Tensor, ref_patches: torch.Tensor, threshold=0.95)
| 75 | |
| 76 | |
| 77 | def eval_LP_IoU(gen_patches: torch.Tensor, ref_patches: torch.Tensor, threshold=0.95): |
| 78 | """compute LP-IoU over two set of patches. |
| 79 | |
| 80 | Args: |
| 81 | gen_patches (torch.Tensor): patches from generated shape |
| 82 | ref_patches (torch.Tensor): patches from reference shape |
| 83 | threshold (float, optional): IoU threshold. Defaults to 0.95. |
| 84 | |
| 85 | Returns: |
| 86 | average max IoU, LP-IoU |
| 87 | """ |
| 88 | values = [] |
| 89 | for i in range(gen_patches.shape[0]): |
| 90 | intersect = torch.logical_and(ref_patches, gen_patches[i:i+1]).sum(dim=(1, 2, 3)) |
| 91 | union = torch.logical_or(ref_patches, gen_patches[i:i+1]).sum(dim=(1, 2, 3)) |
| 92 | max_iou = torch.max(intersect / union) |
| 93 | values.append(max_iou) |
| 94 | values = torch.stack(values) |
| 95 | avg_iou = torch.mean(values).item() |
| 96 | percent = torch.sum((values > threshold).int()).item() * 1.0 / len(values) |
| 97 | return avg_iou, percent |
| 98 | |
| 99 | |
| 100 | def eval_LP_Fscore(gen_patches: torch.Tensor, ref_patches: torch.Tensor, threshold=0.95): |
no outgoing calls
no test coverage detected