Closed pepperbubble closed 1 month ago
Hey @pepperbubble, thanks for the report.
Looking at you code, I see that you pass multiple result and true masks at once to the metric functions.
The metric functions are not made to deal with batch tensors. Instead, as you use them, they interpret the input as a 4D image (the original 3D image plus an additional dimension from the batches). That will lead to different results for different batch sizes.
You can do:
for mask_pred, true_mask in zip(masks_pred, true_masks):
dice = metric.binary.dc(mask_pred, true_mask)
metric_list_dice.append(dice)
thanks! it really helps.
when i change the batchsize on test,the dice score is different
when bs=1,INFO: Mean Dice: 0.868615 INFO: Mean HD95: 10.437061 bs = 2, INFO: Mean Dice: 0.872097 INFO: Mean HD95: 9.246552 bs = 64, INFO: Mean Dice: 0.878093,INFO: Mean HD95: 2.692308