Skip to content

Commit

Permalink
Handle both normalized and denormalized coords in overlay bbox (#115)
Browse files Browse the repository at this point in the history
instead of tool description fixed the code to handle both normalized and denormalized cases
  • Loading branch information
shankar-vision-eng authored Jun 5, 2024
1 parent cff0756 commit ffbe1b1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions vision_agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,9 @@ def overlay_bounding_boxes(
box = elt["bbox"]
scores = elt["score"]

box = [
int(box[0] * width),
int(box[1] * height),
int(box[2] * width),
int(box[3] * height),
]
# denormalize the box if it is normalized
box = denormalize_bbox(box, (height, width))

draw.rectangle(box, outline=color[label], width=4)
text = f"{label}: {scores:.2f}"
text_box = draw.textbbox((box[0], box[1]), text=text, font=font)
Expand Down

0 comments on commit ffbe1b1

Please sign in to comment.