-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding more cv tools to coder agent #88
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
89d78d8
adding more cv tools to coder agent
shankar-vision-eng 245b296
Bug fix: missing kernel python3 (#87)
humpydonkey 92fd2c8
[skip ci] chore(release): vision-agent 0.2.24
AsiaCao d6a01da
adding more cv tools to coder agent
shankar-vision-eng 6604608
Added test cases for the tools added
shankar-vision-eng 3a8d3c4
added test case for every tool
shankar-vision-eng 40a1f2d
complete merge
shankar-vision-eng e565049
fix linting
shankar-vision-eng b44ffa6
fixing tests
shankar-vision-eng d9dd6e7
fix linting
shankar-vision-eng 65abbd3
fixing test cases for grounding tools as the output format changed
shankar-vision-eng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "vision-agent" | ||
version = "0.2.23" | ||
version = "0.2.24" | ||
description = "Toolset for Vision Agent" | ||
authors = ["Landing AI <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -33,6 +33,7 @@ nbclient = "^0.10.0" | |
nbformat = "^5.10.4" | ||
rich = "^13.7.1" | ||
langsmith = "^0.1.58" | ||
ipykernel = "^6.29.4" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
autoflake = "1.*" | ||
|
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,42 +1,84 @@ | ||
import skimage as ski | ||
from PIL import Image | ||
|
||
from vision_agent.tools.tools import CLIP, GroundingDINO, GroundingSAM, ImageCaption | ||
from vision_agent.tools.tools_v2 import ( | ||
clip, | ||
zero_shot_counting, | ||
visual_prompt_counting, | ||
image_question_answering, | ||
ocr, | ||
grounding_dino, | ||
grounding_sam, | ||
image_caption, | ||
) | ||
|
||
|
||
def test_grounding_dino(): | ||
img = Image.fromarray(ski.data.coins()) | ||
result = GroundingDINO()( | ||
img = ski.data.coins() | ||
result = grounding_dino( | ||
prompt="coin", | ||
image=img, | ||
) | ||
assert result["labels"] == ["coin"] * 24 | ||
assert len(result["bboxes"]) == 24 | ||
assert len(result["scores"]) == 24 | ||
assert len(result) == 24 | ||
assert [res["label"] for res in result] == ["coin"] * 24 | ||
|
||
|
||
def test_grounding_sam(): | ||
img = Image.fromarray(ski.data.coins()) | ||
result = GroundingSAM()( | ||
img = ski.data.coins() | ||
result = grounding_sam( | ||
prompt="coin", | ||
image=img, | ||
) | ||
assert result["labels"] == ["coin"] * 24 | ||
assert len(result["bboxes"]) == 24 | ||
assert len(result["scores"]) == 24 | ||
assert len(result["masks"]) == 24 | ||
assert len(result) == 24 | ||
assert [res["label"] for res in result] == ["coin"] * 24 | ||
assert len([res["mask"] for res in result]) == 24 | ||
|
||
|
||
def test_clip(): | ||
img = Image.fromarray(ski.data.coins()) | ||
result = CLIP()( | ||
prompt="coins", | ||
img = ski.data.coins() | ||
result = clip( | ||
classes=["coins", "notes"], | ||
image=img, | ||
) | ||
assert result["scores"] == [1.0] | ||
assert result["scores"] == [0.9999, 0.0001] | ||
|
||
|
||
def test_image_caption() -> None: | ||
img = Image.fromarray(ski.data.coins()) | ||
result = ImageCaption()(image=img) | ||
assert result["text"] | ||
img = ski.data.rocket() | ||
result = image_caption( | ||
image=img, | ||
) | ||
assert result.strip() == "a rocket on a stand" | ||
|
||
|
||
def test_zero_shot_counting() -> None: | ||
img = ski.data.coins() | ||
result = zero_shot_counting( | ||
image=img, | ||
) | ||
assert result["count"] == 21 | ||
|
||
|
||
def test_visual_prompt_counting() -> None: | ||
img = ski.data.coins() | ||
result = visual_prompt_counting( | ||
visual_prompt={"bbox": [85, 106, 122, 145]}, | ||
image=img, | ||
) | ||
assert result["count"] == 25 | ||
|
||
|
||
def test_image_question_answering() -> None: | ||
img = ski.data.rocket() | ||
result = image_question_answering( | ||
prompt="Is the scene captured during day or night ?", | ||
image=img, | ||
) | ||
assert result.strip() == "night" | ||
|
||
|
||
def test_ocr() -> None: | ||
img = ski.data.page() | ||
result = ocr( | ||
image=img, | ||
) | ||
assert any("Region-based segmentation" in res["label"] for res in result) |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!