MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / iou

Function iou

test_polyp.py:26–34  ·  view source on GitHub ↗
(predicted, labels)

Source from the content-addressed store, hash-verified

24 return (2. * intersection + smooth) / (total + smooth)
25
26def iou(predicted, labels):
27 if predicted.device != labels.device:
28 labels = labels.to(predicted.device)
29 smooth = 1e-6
30 predicted_flat = predicted.contiguous().view(-1)
31 labels_flat = labels.contiguous().view(-1)
32 intersection = (predicted_flat * labels_flat).sum()
33 union = predicted_flat.sum() + labels_flat.sum() - intersection
34 return (intersection + smooth) / (union + smooth)
35
36def get_binary_metrics(pred, gt):
37 tp = (pred * gt).sum().item()

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected