Question about calculating IoU.
Closed this issue · 2 comments
Thanks for your great work at first~
You calculated IoU of voxels in core/test.py line129-134. I have some questions about that.
Line 133: union = torch.sum(torch.ge(_volume.add(ground_truth_volume), 1)).float()
I think a union includes 3 parts:
- volume = 1 and gt = 1 => 1+1=2
- volume = 0 and gt = 1 => 0+1=1
- volume = 1 and gt = 0 => 1+0=1
But I find that in your code, it only includes 2) and 3). Because you throw away the voxel-pair, whose sum is 2, by torch.ge(add_reslut,1).
Am I wrong somewhere? Looking for reply.
Best regards.
I don't think there's anything wrong with this code.
The following code
_volume = torch.ge(generated_volume, th).float()
union = torch.sum(torch.ge(_volume.add(ground_truth_volume), 1)).float()
is equivalent to
_volume = _volume >= th
_volume = _volume + ground_truth_volume
_volume = _volume >= 1
union = torch.sum(_volume).float()
If you cannot understand the code above, you can implement it by yourself. And you will find that the results are the same.
Ok thanks a lot ! I got mess with torch.ge(), thanks for your patient explanation !