Skip to content

Commit

Permalink
fix bbox coords outside the image, countgd return types
Browse files Browse the repository at this point in the history
  • Loading branch information
shankar-vision-eng committed Sep 1, 2024
1 parent ba594e4 commit 7d64451
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vision_agent/tools/tool_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inspect
import logging
import os
from typing import Any, Callable, Dict, List, MutableMapping, Optional, Tuple
from typing import Any, Callable, Dict, List, MutableMapping, Optional, Tuple, Union

import pandas as pd
from IPython.display import display
Expand Down Expand Up @@ -34,7 +34,7 @@ def send_inference_request(
files: Optional[List[Tuple[Any, ...]]] = None,
v2: bool = False,
metadata_payload: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
) -> Union[Dict[str, Any], List[Dict[str, Any]]]:
# TODO: runtime_tag and function_name should be metadata_payload and now included
# in the service payload
try:
Expand Down
5 changes: 4 additions & 1 deletion vision_agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,10 @@ def overlay_counting_results(
fontsize = max(10, int(min(width, height) / 80))
pil_image = ImageEnhance.Brightness(pil_image).enhance(0.5)
draw = ImageDraw.Draw(pil_image)
font = ImageFont.load_default(size=fontsize)
font = ImageFont.truetype(
str(resources.files("vision_agent.fonts").joinpath("default_font_ch_en.ttf")),
fontsize,
)

for i, elt in enumerate(instances):
label = f"{i}"
Expand Down
2 changes: 1 addition & 1 deletion vision_agent/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def denormalize_bbox(
raise ValueError("Bounding box must be of length 4.")

arr = np.array(bbox)
if np.all((arr >= 0) & (arr <= 1)):
if np.all((arr[:2] >= 0) & (arr[:2] <= 1)):
x1, y1, x2, y2 = bbox
x1 = round(x1 * image_size[1])
y1 = round(y1 * image_size[0])
Expand Down

0 comments on commit 7d64451

Please sign in to comment.