Skip to content

Instantly share code, notes, and snippets.

@Kautenja
Kautenja / iou.py
Last active June 1, 2021 12:10
An implementation of the Intersection over Union (IoU) metric for Keras.
"""An implementation of the Intersection over Union (IoU) metric for Keras."""
from keras import backend as K
def iou(y_true, y_pred, label: int):
"""
Return the Intersection over Union (IoU) for a given label.
Args:
y_true: the expected y values as a one-hot