MCPcopy Create free account
hub / github.com/CompVis/diff2flow / apply_scale_and_shift

Function apply_scale_and_shift

diff2flow/dataset/depth_utils.py:66–81  ·  view source on GitHub ↗

Returns a scale-and-shift version of pred according to gt Args: pred: predicted image (b, c, h, w) gt : ground truth image (b, c, h, w)

(pred, gt, mask=None)

Source from the content-addressed store, hash-verified

64
65
66def apply_scale_and_shift(pred, gt, mask=None):
67 """
68 Returns a scale-and-shift version of pred according to gt
69
70 Args:
71 pred: predicted image (b, c, h, w)
72 gt : ground truth image (b, c, h, w)
73 """
74 assert pred.shape == gt.shape, "pred and gt must have the same shape"
75 if mask is not None:
76 assert pred.shape == mask.shape, "pred and mask must have the same shape"
77 shifts, scales = get_batch_scale_and_shift(gt, pred, mask=mask)
78 shifts = shifts[:, None, None, None]
79 scales = scales[:, None, None, None]
80 pred_scaled = shifts + scales*pred
81 return pred_scaled
82
83
84def abs_rel_error(pred, target, valid_mask=None):

Callers 1

__call__Method · 0.90

Calls 1

Tested by

no test coverage detected