Inconsistent representation of box in torchvision.ops
See original GitHub issueFeature suggestion
When checking the how the new operations in the torchvision 0.11 work, I found an inconsistency between different function.
import torchvision.ops as tops
import torch
import torch.nn as nn
a = torch.zeros(1, 1, 8, 8)
a[..., :4, 4:] = 1
bbox = tops.masks_to_boxes((a==1)[0].float())
area = tops.box_area(bbox) # the returned area is 9 which should be 16
new_box = tops.box_convert(bbox, 'xyxy', 'xywh') # which returns [4, 4, 3, 3] => expected output [4, 4, 4, 4]
Suggest a potential alternative/fix
This is not actually an error but could cause confusion.
I suggest to make the box representations between different function more consistent.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (20 by maintainers)
Top Results From Across the Web
[BUG] Pytorch-> Inconsistent conversion torchvision.ops.nms ...
Hi everyone, I encounter a strange issue. I tried to convert detectron2 RoI Heads, I could convert it to ONNX successfully, but I...
Read more >torchvision.ops — Torchvision 0.11.0 documentation - PyTorch
'cxcywh' : boxes are represented via centre, width and height, cx, cy being center of box, w, h being width and height. Parameters....
Read more >torchvision Changelog - pyup.io
torchvision ops are now natively supported by torchscript. This includes operators such ... Fix inconsistent NMS implementation between CPU and CUDA (1556)
Read more >The Need for Consistency in Object Detection - arXiv
accuracy metrics do not properly account for inconsistency, ... dashed-line box) while the man is detected (green solid box).
Read more >ReduNet: A White-box Deep Network from the Principle of ...
Keywords: rate reduction, white-box deep network, linear discriminative representation, multi-channel convolution, sparsity and invariance trade-off.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We should return area / sizes as
x2 - x1
, and notx2 - x1 + 1
as it was previously done in early versions of other libraries (like Detectron).This was a deliberate decision, and as @rbgirshick pointed out in the past
Thanks.
Then I’m not sure this 0 vs 1 indexing discussion is relevant to what we’re concerned with here. Python is 0-based and we’re following that too.
The problem we have here is the relation between x1 - x0 and y1 - y0, and how it plays out in the area calculation, and other conversions. Those concerns are valid whether one uses 0 or 1-based indexing, but I don’t think we should worry about supporting 1-based indexing.