Skip to content

Commit

Permalink
formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed Apr 12, 2024
1 parent 737413b commit 3e1f25d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ def chat(
image: Optional[Union[str, Path]] = None,
visualize_output: Optional[bool] = False,
) -> str:
answer, _ = self.chat_with_workflow(chat, image=image, visualize_output=visualize_output)
answer, _ = self.chat_with_workflow(
chat, image=image, visualize_output=visualize_output
)
return answer

def retrieval(
Expand Down
7 changes: 5 additions & 2 deletions vision_agent/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def overlay_bboxes(
fontsize = max(12, int(min(width, height) / 40))
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(
str(resources.files("vision_agent.fonts").joinpath("default_font_ch_en.ttf")), fontsize
str(resources.files("vision_agent.fonts").joinpath("default_font_ch_en.ttf")),
fontsize,
)
if "bboxes" not in bboxes:
return image.convert("RGB")
Expand Down Expand Up @@ -147,7 +148,9 @@ def overlay_masks(
elif isinstance(image, np.ndarray):
image = Image.fromarray(image)

color = {label: COLORS[i % len(COLORS)] for i, label in enumerate(set(masks["labels"]))}
color = {
label: COLORS[i % len(COLORS)] for i, label in enumerate(set(masks["labels"]))
}
if "masks" not in masks:
return image.convert("RGB")

Expand Down
26 changes: 15 additions & 11 deletions vision_agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class Tool(ABC):

class NoOp(Tool):
name = "noop_"
description = (
"'noop_' is a no-op tool that does nothing if you do not want answer the question directly and not use a tool."
)
description = "'noop_' is a no-op tool that does nothing if you do not want answer the question directly and not use a tool."
usage = {
"required_parameters": [],
"examples": [
Expand Down Expand Up @@ -180,7 +178,10 @@ class GroundingDINO(Tool):
},
{
"scenario": "Can you detect the person on the left and right? Image name: person.jpg",
"parameters": {"prompt": "left person. right person", "image": "person.jpg"},
"parameters": {
"prompt": "left person. right person",
"image": "person.jpg",
},
},
{
"scenario": "Detect the red shirts and green shirst. Image name: shirts.jpg",
Expand Down Expand Up @@ -286,7 +287,10 @@ class GroundingSAM(Tool):
},
{
"scenario": "Can you segment the person on the left and right? Image name: person.jpg",
"parameters": {"prompt": "left person. right person", "image": "person.jpg"},
"parameters": {
"prompt": "left person. right person",
"image": "person.jpg",
},
},
{
"scenario": "Can you build me a tool that segments red shirts and green shirts? Image name: shirts.jpg",
Expand Down Expand Up @@ -496,9 +500,7 @@ def __call__(self, masks: Union[str, Path]) -> float:

class BboxIoU(Tool):
name = "bbox_iou_"
description = (
"'bbox_iou_' returns the intersection over union of two bounding boxes. This is a good tool for determining if two objects are overlapping."
)
description = "'bbox_iou_' returns the intersection over union of two bounding boxes. This is a good tool for determining if two objects are overlapping."
usage = {
"required_parameters": [
{"name": "bbox1", "type": "List[int]"},
Expand Down Expand Up @@ -602,7 +604,9 @@ class Calculator(Tool):
r"""Calculator is a tool that can perform basic arithmetic operations."""

name = "calculator_"
description = "'calculator_' is a tool that can perform basic arithmetic operations."
description = (
"'calculator_' is a tool that can perform basic arithmetic operations."
)
usage = {
"required_parameters": [{"name": "equation", "type": "str"}],
"examples": [
Expand All @@ -613,8 +617,8 @@ class Calculator(Tool):
{
"scenario": "If you want to calculate (4 + 2.5) / 2.1",
"parameters": {"equation": "(4 + 2.5) / 2.1"},
}
]
},
],
}

def __call__(self, equation: str) -> float:
Expand Down

0 comments on commit 3e1f25d

Please sign in to comment.