pytorch-nested-unet icon indicating copy to clipboard operation
pytorch-nested-unet copied to clipboard

Incorrect IOU definition

Open nzw0301 opened this issue 5 years ago • 2 comments

The current IOU implementation has calculated the union and intersection over samples in a mini-batch, then it has calculated the IOU score. But I think IOU should be calculated per sample then take the mean over the samples in the mini-batch.

I think the following code is correct when the number of classes is 1:

intersection = (output_ & target_).sum(axis=(1, 2, 3))
union = (output_ | target_).sum(axis=(1, 2, 3))

return (intersection + smooth) / (union + smooth).mean()

nzw0301 avatar Nov 22 '20 12:11 nzw0301

Hi, will that IOU score higher?

zhou-rui1 avatar Nov 28 '20 03:11 zhou-rui1

@zhou-rui1 I don't think so. The current implementation might output a much higher score.

nzw0301 avatar Nov 28 '20 17:11 nzw0301