MCPcopy Create free account
hub / github.com/DIVE128/DMVSNet / compute_metrics_for_each_image

Function compute_metrics_for_each_image

tools.py:160–173  ·  view source on GitHub ↗
(metric_func)

Source from the content-addressed store, hash-verified

158
159# a wrapper to compute metrics for each image individually
160def compute_metrics_for_each_image(metric_func):
161 def wrapper(depth_est, depth_gt, mask, *args):
162 batch_size = depth_gt.shape[0]
163 results = []
164 # compute result one by one
165 for idx in range(batch_size):
166 ret = metric_func(depth_est[idx], depth_gt[idx], mask[idx], *args)
167 if torch.isnan(ret):
168 results.append(torch.zeros_like(ret))
169 else:
170 results.append(ret)
171 return torch.stack(results).mean()
172
173 return wrapper
174
175
176@torch.no_grad()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected