MCPcopy Create free account
hub / github.com/Sin3DM/Sin3DM / eval_LP_IoU

Function eval_LP_IoU

evaluation/patch_utils.py:77–97  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

75
76
77def 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
100def eval_LP_Fscore(gen_patches: torch.Tensor, ref_patches: torch.Tensor, threshold=0.95):

Callers 1

eval_LP_given_pathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected