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

Function dice_coefficient

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

Source from the content-addressed store, hash-verified

30 return (w * (wbce + wiou)).mean()
31
32def dice_coefficient(predicted, labels):
33 if predicted.device != labels.device:
34 labels = labels.to(predicted.device)
35 smooth = 1e-6
36 predicted_flat = predicted.contiguous().view(-1)
37 labels_flat = labels.contiguous().view(-1)
38 intersection = (predicted_flat * labels_flat).sum()
39 total = predicted_flat.sum() + labels_flat.sum()
40 return (2. * intersection + smooth) / (total + smooth)
41
42def iou(predicted, labels):
43 if predicted.device != labels.device:

Callers 1

testFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected