draw_bounding_boxes should check that (W, H) >= (xmax, ymax) >= (xmin, ymin) >= (0, 0)
See original GitHub issue🚀 The feature
Currently, draw_bounding_boxes
does not sanity check the input bounding boxes to ensure that (xmax, ymax) >= (xmin, ymin)
. This can lead to unexpected output that can be difficult to debug if the user, say, inputs boxes in cxcywh format.
I could make a PR for this if needed but would prefer if someone else did it since I have my hands full with a PR I’m working on for PyTorch proper.
Motivation, pitch
I personally just ran into this problem and I thought something was wrong with my network for a while.
Currently, the box conversion ops do this check, and it seems at least as important to do the same check in draw_bounding_boxes
.
Alternatives
No response
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
python - How to draw bounding box with xmin,xmax,ymin,ymax
You can use cv2.rectangle in to draw a bounding box. An example is given below: # cv2 image = cv2.rectangle(image, (xmin,ymin), (xmax,ymax), ...
Read more >draw_bounding_boxes — Torchvision main documentation
Note that the boxes are absolute coordinates with respect to the image. In other words: 0 <= xmin < xmax < W and...
Read more >Source code for motrackers.utils.misc - Aditya M. Deshpande
Returns: numpy.ndarray : Bounding box coordinates as `(xmin, ymin, xmax, ymax)`. """ if len(xywh.shape) == 2: x = xywh[:, 0] + xywh[:, 2]...
Read more >How to draw bounding boxes on an image in ... - Tutorialspoint
Each bounding box should contain four points in (xmin, ymin, xmax, ymax) format. In other words: 0 ≤ xmin < xmax < W,...
Read more >Implementing YOLOV2 from scratch using Tensorflow 2.0
def __init__(self, xmin, ymin, xmax, ymax, confidence=None,classes=None): ... print("cebter_x abd cebter_w should range between 0 and ...
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 Free
Top 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
I could look into this if no one else is.
@pmeier I knew that
draw_bounding_boxes
requires “xyxy”, but I got confused about which format my bounding boxes were at that particular point in the code, since I’m using a DETR model where the model outputs cxcywh, but xyxy is used for the GIOU loss, and my dataset uses xyxy format.The class abstraction definitely sounds like a good idea. I still think though that it would be a good idea to add this check to the “functional” version
draw_bounding_box
API, especially since the conversion ops already do it.