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

Function eval_LP_given_paths

evaluation/patch_utils.py:125–166  ·  view source on GitHub ↗
(data_paths, ref_path, patch_size=11, stride=5, patch_num=1000, device="cpu")

Source from the content-addressed store, hash-verified

123
124
125def eval_LP_given_paths(data_paths, ref_path, patch_size=11, stride=5, patch_num=1000, device="cpu"):
126 random.seed(1234)
127
128 # load reference
129 gen_data_shape = load_voxgrid(data_paths[0], resolution=128, device=device).shape
130 ref_data = load_sdfgrid2vox(ref_path, resolution=128, device=device)
131
132 ref_patches = extract_valid_patches_unfold(ref_data, patch_size, stride)
133
134 # LP
135 result_lp_iou_avg = []
136 result_lp_iou_percent = []
137 result_lp_fscore_avg = []
138 result_lp_fscore_percent = []
139
140 for path in tqdm(data_paths, desc="LP-IOU/F-score"):
141 gen_data = load_voxgrid(path, resolution=128, device=device)
142
143 gen_patches = extract_valid_patches_unfold(gen_data, patch_size, stride)
144 indices = list(range(gen_patches.shape[0]))
145 random.shuffle(indices)
146 indices = indices[:patch_num]
147 gen_patches = gen_patches[indices]
148
149 lp_iou_avg, lp_iou_percent = eval_LP_IoU(gen_patches, ref_patches)
150 lp_fscore_avg, lp_fscore_percent = eval_LP_Fscore(gen_patches, ref_patches)
151
152 result_lp_iou_avg.append(lp_iou_avg)
153 result_lp_iou_percent.append(lp_iou_percent)
154 result_lp_fscore_avg.append(lp_fscore_avg)
155 result_lp_fscore_percent.append(lp_fscore_percent)
156
157 result_lp_iou_avg = np.mean(result_lp_iou_avg).round(6)
158 result_lp_fscore_avg = np.mean(result_lp_fscore_avg).round(6)
159 result_lp_iou_percent = np.mean(result_lp_iou_percent).round(6)
160 result_lp_fscore_percent = np.mean(result_lp_fscore_percent).round(6)
161
162 eval_results = {'LP-IOU-avg': result_lp_iou_avg,
163 'LP-IOU-percent': result_lp_iou_percent,
164 'LP-F-score-avg': result_lp_fscore_avg,
165 'LP-F-score-percent': result_lp_fscore_percent}
166 return eval_results
167
168
169def eval_Div_given_paths(data_paths, device="cpu"):

Callers 1

eval_full.pyFile · 0.90

Calls 6

load_voxgridFunction · 0.85
load_sdfgrid2voxFunction · 0.85
tqdmFunction · 0.85
eval_LP_IoUFunction · 0.85
eval_LP_FscoreFunction · 0.85

Tested by

no test coverage detected