(outputs: np.array, labels: np.array)
| 203 | return eiou / len(threshold), edice / len(threshold) |
| 204 | |
| 205 | def iou(outputs: np.array, labels: np.array): |
| 206 | |
| 207 | SMOOTH = 1e-6 |
| 208 | intersection = (outputs & labels).sum((1, 2)) |
| 209 | union = (outputs | labels).sum((1, 2)) |
| 210 | |
| 211 | iou = (intersection + SMOOTH) / (union + SMOOTH) |
| 212 | |
| 213 | |
| 214 | return iou.mean() |
| 215 | |
| 216 | def dice_coeff(input, target): |
| 217 | """Dice coeff for batches""" |