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)
| 64 | |
| 65 | |
| 66 | def 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 | |
| 84 | def abs_rel_error(pred, target, valid_mask=None): |
no test coverage detected