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

Function iou

train_polyp.py:42–50  ·  view source on GitHub ↗
(predicted, labels)

Source from the content-addressed store, hash-verified

40 return (2. * intersection + smooth) / (total + smooth)
41
42def iou(predicted, labels):
43 if predicted.device != labels.device:
44 labels = labels.to(predicted.device)
45 smooth = 1e-6
46 predicted_flat = predicted.contiguous().view(-1)
47 labels_flat = labels.contiguous().view(-1)
48 intersection = (predicted_flat * labels_flat).sum()
49 union = predicted_flat.sum() + labels_flat.sum() - intersection
50 return (intersection + smooth) / (union + smooth)
51
52def test(model, path, dataset, opt):
53 data_path = os.path.join(path, dataset)

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected