From ffbe1b1a18bc73c0379f7c3b34447f0e121d0152 Mon Sep 17 00:00:00 2001 From: Shankar <90070882+shankar-vision-eng@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:06:12 -0700 Subject: [PATCH] Handle both normalized and denormalized coords in overlay bbox (#115) instead of tool description fixed the code to handle both normalized and denormalized cases --- vision_agent/tools/tools.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vision_agent/tools/tools.py b/vision_agent/tools/tools.py index a2c76156..626f93e6 100644 --- a/vision_agent/tools/tools.py +++ b/vision_agent/tools/tools.py @@ -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)