MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / dice_coeff

Function dice_coeff

func_3d/utils.py:216–226  ·  view source on GitHub ↗

Dice coeff for batches

(input, target)

Source from the content-addressed store, hash-verified

214 return iou.mean()
215
216def dice_coeff(input, target):
217 """Dice coeff for batches"""
218 if input.is_cuda:
219 s = torch.FloatTensor(1).to(device = input.device).zero_()
220 else:
221 s = torch.FloatTensor(1).zero_()
222
223 for i, c in enumerate(zip(input, target)):
224 s = s + DiceCoeff().forward(c[0], c[1])
225
226 return s / (i + 1)
227
228class DiceCoeff(Function):
229 """Dice coeff for individual examples"""

Callers 1

eval_segFunction · 0.70

Calls 2

DiceCoeffClass · 0.70
forwardMethod · 0.45

Tested by

no test coverage detected