-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added iou tools * add image visualization for reflection * update tool return format * typing and flake8 issues * added visualized images to all_tool_results
- Loading branch information
1 parent
fdae1fd
commit bbe0a68
Showing
6 changed files
with
339 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import tempfile | ||
|
||
import numpy as np | ||
from PIL import Image | ||
|
||
from vision_agent.tools.tools import BboxIoU, SegIoU | ||
|
||
|
||
def test_bbox_iou(): | ||
bbox1 = [0, 0, 0.75, 0.75] | ||
bbox2 = [0.25, 0.25, 1, 1] | ||
assert BboxIoU()(bbox1, bbox2) == 0.29 | ||
|
||
|
||
def test_seg_iou(): | ||
mask1 = np.zeros((10, 10), dtype=np.uint8) | ||
mask1[2:4, 2:4] = 255 | ||
mask2 = np.zeros((10, 10), dtype=np.uint8) | ||
mask2[3:5, 3:5] = 255 | ||
with tempfile.TemporaryDirectory() as tmpdir: | ||
mask1_path = os.path.join(tmpdir, "mask1.png") | ||
mask2_path = os.path.join(tmpdir, "mask2.png") | ||
Image.fromarray(mask1).save(mask1_path) | ||
Image.fromarray(mask2).save(mask2_path) | ||
assert SegIoU()(mask1_path, mask2_path) == 0.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
from .prompts import CHOOSE_PARAMS, SYSTEM_PROMPT | ||
from .tools import CLIP, TOOLS, Counter, Crop, GroundingDINO, GroundingSAM, Tool | ||
from .tools import ( | ||
CLIP, | ||
TOOLS, | ||
BboxArea, | ||
BboxIoU, | ||
Counter, | ||
Crop, | ||
ExtractFrames, | ||
GroundingDINO, | ||
GroundingSAM, | ||
SegArea, | ||
SegIoU, | ||
Tool, | ||
) |
Oops, something went wrong.