def iou_3(y_true, y_pred, per_image=True): return iou_score(y_true[:, :, :, 3], y_pred[:, :, :, 3], per_image=per_image)
def test_iou_metric(case): gt, pr, res = case gt = _to_4d(gt) pr = _to_4d(pr) score = K.eval(iou_score(gt, pr)) assert np.allclose(score, res)
def iou_metric_occlusion(t, p): return iou_score(t[..., 4:5], K.one_hot(K.argmax(p), 5)[..., 4:5])
def iou_metric_binary(t, p): p = K.cast(p > 0.5, K.floatx()) return iou_score(t, p)
def iou_metric_cold(t, p): return iou_score(t[..., 2:3], K.one_hot(K.argmax(p), 5)[..., 2:3])
def iou_metric_stationary(t, p): return iou_score(t[..., 3:4], K.one_hot(K.argmax(p), 5)[..., 3:4])
def iou_metric_hot(t, p): return iou_score(t[..., 1:2], K.one_hot(K.argmax(p), 5)[..., 1:2])
def iou_metric_fronts(t, p): return iou_score(t[..., 1:], K.one_hot(K.argmax(p, axis=-1), 5)[..., 1:])
def iou_metric_all(t, p): return iou_score(t, K.one_hot(K.argmax(p, axis=-1), 5))
def iou_metric_forced_binary(t, p): p = K.cast(K.argmax(p, axis=-1) > 0, K.floatx()) t = K.cast(K.argmax(t, axis=-1) > 0, K.floatx()) return iou_score(t, p)
def test_threshold_iou(case): gt, pr, res = case gt = _to_4d(gt) pr = _to_4d(pr) * 0.51 score = K.eval(iou_score(gt, pr, smooth=10e-12, threshold=0.5)) assert np.allclose(score, res)