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.

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
singhularAdicommented, Mar 16, 2022

I could look into this if no one else is.

3reactions
norabelrosecommented, Mar 3, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

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