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

Function dice_coeff

func_2d/utils.py:269–279  ·  view source on GitHub ↗

Dice coeff for batches

(input, target)

Source from the content-addressed store, hash-verified

267
268
269def dice_coeff(input, target):
270 """Dice coeff for batches"""
271 if input.is_cuda:
272 s = torch.FloatTensor(1).to(device = input.device).zero_()
273 else:
274 s = torch.FloatTensor(1).zero_()
275
276 for i, c in enumerate(zip(input, target)):
277 s = s + DiceCoeff().forward(c[0], c[1])
278
279 return s / (i + 1)
280
281
282

Callers 1

eval_segFunction · 0.70

Calls 2

DiceCoeffClass · 0.70
forwardMethod · 0.45

Tested by

no test coverage detected