mmcv icon indicating copy to clipboard operation
mmcv copied to clipboard

wrong result of differentiable 3D IoU, occurring larger than 1

Open Angericky opened this issue 2 years ago • 7 comments

Hello,

I apply function diff_iou_rotated_3d from mmcv.ops to implement 3D IoU loss. However, the computed IoU can be larger than 1 in some circumstances, which is wrong by definition. But if I compute the specified predicition and target where IoU > 1 occurred, the result might be right.

This bug could be related to parallelization in cuda file, but I couldn't locate the problem code.

Angericky avatar Apr 28 '22 09:04 Angericky

For easy reproduction, I upload arrays causing the bug. The zip file contains 2 .npy files separately including prediction and label numpy array. Use diff_iou_rotated_3d function can reproduce the bug.

boxes.zip

Angericky avatar Apr 28 '22 09:04 Angericky

Thanks for your feedback~ maybe @zytx121 could have a look.

HAOCHENYE avatar Apr 28 '22 14:04 HAOCHENYE

It's a little strange. When I run this code, all results are smaller than 1. So, I can't reproduce the bug.

label = torch.from_numpy(np.load("label.npy")).cuda()
pred = torch.from_numpy(np.load("pred_diff.npy")).cuda()
ious = diff_iou_rotated_3d(label, pred).cpu()

for i in range(ious.shape[0]):
    for j in range(ious.shape[1]):
        print(ious[i][j])

results.txt

zytx121 avatar Apr 29 '22 00:04 zytx121

That's weird... I use the same code and get 3.5672 with index of [15, 51]. My pytorch version is 1.10.1 and cuda version 10.2. What's your environment?

Angericky avatar Apr 29 '22 04:04 Angericky

My pytorch version is 1.7 and cuda version is the same as you.

zytx121 avatar Apr 29 '22 07:04 zytx121

I downgrade pytorch to 1.7 and the bug still exists. Oh I found the wrong value 3.5672 in your result.txt at line 1972

Angericky avatar Apr 29 '22 10:04 Angericky

Hi @Angericky ,

According to the author of the original rotated iou implementation the result may be inaccurate in some corner cases 1, 2. Actually it is a bug. However even in current implementation the rotated iou loss is extremely useful for object detection 3, 4.

filaPro avatar Apr 30 '22 15:04 filaPro