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

Function dice_coefficient

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

Source from the content-addressed store, hash-verified

14from medpy.metric.binary import hd95
15
16def dice_coefficient(predicted, labels):
17 if predicted.device != labels.device:
18 labels = labels.to(predicted.device)
19 smooth = 1e-6
20 predicted_flat = predicted.contiguous().view(-1)
21 labels_flat = labels.contiguous().view(-1)
22 intersection = (predicted_flat * labels_flat).sum()
23 total = predicted_flat.sum() + labels_flat.sum()
24 return (2. * intersection + smooth) / (total + smooth)
25
26def iou(predicted, labels):
27 if predicted.device != labels.device:

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected