is it a small bug in batch_dice??????
CodingHHW opened this issue · comments
in the medicaldetectiontoolkit/utils/model_utils.py, lines 883, batch_dice loss function,
I think should add
if y[:, 1:, ...].max() == 0:
y = 1 - y
pred = 1 - pred
for the patch maybe it has no roi
Hi CodingHHW,
thanks for your concern.
Since the dice loss is implemented over the whole batch, it is unlikely a class will not at all be present, however it is possible.
For that case, I have added an additive smooth which handles this special case and is negligible in other cases (this commit).