MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / compute_errors

Function compute_errors

dzoedepth/utils/misc.py:159–199  ·  view source on GitHub ↗

Compute metrics for 'pred' compared to 'gt' Args: gt (numpy.ndarray): Ground truth values pred (numpy.ndarray): Predicted values gt.shape should be equal to pred.shape Returns: dict: Dictionary containing the following metrics: 'a1': Delta1 accu

(gt, pred)

Source from the content-addressed store, hash-verified

157
158
159def compute_errors(gt, pred):
160 """Compute metrics for 'pred' compared to 'gt'
161
162 Args:
163 gt (numpy.ndarray): Ground truth values
164 pred (numpy.ndarray): Predicted values
165
166 gt.shape should be equal to pred.shape
167
168 Returns:
169 dict: Dictionary containing the following metrics:
170 'a1': Delta1 accuracy: Fraction of pixels that are within a scale factor of 1.25
171 'a2': Delta2 accuracy: Fraction of pixels that are within a scale factor of 1.25^2
172 'a3': Delta3 accuracy: Fraction of pixels that are within a scale factor of 1.25^3
173 'abs_rel': Absolute relative error
174 'rmse': Root mean squared error
175 'log_10': Absolute log10 error
176 'sq_rel': Squared relative error
177 'rmse_log': Root mean squared error on the log scale
178 'silog': Scale invariant log error
179 """
180 thresh = np.maximum((gt / pred), (pred / gt))
181 a1 = (thresh < 1.25).mean()
182 a2 = (thresh < 1.25 ** 2).mean()
183 a3 = (thresh < 1.25 ** 3).mean()
184
185 abs_rel = np.mean(np.abs(gt - pred) / gt)
186 sq_rel = np.mean(((gt - pred) ** 2) / gt)
187
188 rmse = (gt - pred) ** 2
189 rmse = np.sqrt(rmse.mean())
190
191 rmse_log = (np.log(gt) - np.log(pred)) ** 2
192 rmse_log = np.sqrt(rmse_log.mean())
193
194 err = np.log(pred) - np.log(gt)
195 silog = np.sqrt(np.mean(err ** 2) - np.mean(err) ** 2) * 100
196
197 log_10 = (np.abs(np.log10(gt) - np.log10(pred))).mean()
198 return dict(a1=a1, a2=a2, a3=a3, abs_rel=abs_rel, rmse=rmse, log_10=log_10, rmse_log=rmse_log,
199 silog=silog, sq_rel=sq_rel)
200
201
202def compute_metrics(gt, pred, interpolate=True, garg_crop=False, eigen_crop=True, dataset='nyu', min_depth_eval=0.1, max_depth_eval=10, **kwargs):

Callers 1

compute_metricsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected