question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi @lilanxiao ,

Maybe I’m missing something but:

device = torch.device('cuda:0')
box_0 = torch.tensor([.0, .0, 2., 2., .0], device=device)
box_1 = torch.tensor([.0, 2., 2., 2., .0], device=device)
print(cal_iou(box_0[None, None, ...], box_1[None, None, ...])[0].cpu().numpy())

returns [[0.33333334]]. However, these 2 boxes are not intersecting.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
lilanxiaocommented, Oct 29, 2020

@kevinghst thank you for the issue! Yeah, it seems my dark magic didn’t work. The true reason of the error was the vertices of the intersection polygon were duplicated (we only need 4, but would get 8) if the two boxes were exactly the same. In this case, the shoelace formula was broken. Also, there was still some numerically instability in my code.

I hope the bug is now properly fixed in commit 6267cefca26cbcd742bfb3cc4ae8064ba0b7a1da . This time I’ve modified the CUDA part and removed the magic. BTW, please remember to re-compile the CUDA extension.

1reaction
filaProcommented, Oct 26, 2020

Probably this EPSILON stuff is not the best idea here. After replacing

t = den_t / (num + EPSILON) 
mask_t = (t >= 0) * (t < 1)
...
u = - den_u / (num + EPSILON)
mask_u = (u >= 0) * (u < 1)  

with

t = den_t / num
t[num == .0] = -1.
mask_t = (t >= 0) * (t <= 1)
...
u = -den_u / num
u[num == .0] = -1.
mask_u = (u >= 0) * (u <= 1)  

everything looks fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incorrect IOU values obtained in a segmentation task using ...
I am measuring IOU and Dice values using a set of ground truth and predicted masks that are generated by a U-Net model....
Read more >
Incorrect IOU definition #36 - 4uiiurz1/pytorch-nested-unet
The current IOU implementation has calculated the union and intersection over samples in a mini-batch, then it has calculated the IOU score.
Read more >
IoU a better detection evaluation metric | by Eric Hofesmann
High confidence false positives; Individual samples to spot check performance; Performance on classes most relevant to your task. What is mAP?
Read more >
Intersection over Union (IoU) for object detection
Intersection over Union (IoU) for object detection ... labels where your model outputs a single label that is either correct or incorrect.
Read more >
Understanding intersection-over-union - Caleb Robinson
Intersection-over-union (IoU), also known as the Jaccard index, is a commonly used measure for determining how accurate a proposed image ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found