-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,48 @@ | ||
import pathlib | ||
|
||
import imgviz | ||
import pytest | ||
|
||
from . import apis | ||
from . import types | ||
|
||
here = pathlib.Path(__file__).resolve().parent | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model", | ||
["efficientsam:10m", "efficientsam:latest", "sam:100m", "sam:300m", "sam:latest"], | ||
) | ||
def test_generate_point_to_mask(model: str) -> None: | ||
image = imgviz.io.imread(here / "_data" / "dogs.jpg") | ||
request: types.GenerateRequest = types.GenerateRequest(model=model, image=image) | ||
response: types.GenerateResponse = apis.generate(request=request) | ||
|
||
assert response.model == model | ||
|
||
assert len(response.annotations) == 1 | ||
annotation: types.Annotation = response.annotations[0] | ||
assert annotation.text is None | ||
assert annotation.score is None | ||
assert annotation.mask is not None | ||
assert annotation.mask.dtype == bool | ||
assert annotation.mask.shape == image.shape[:2] | ||
|
||
|
||
def test_generate_text_to_bounding_box() -> None: | ||
model: str = "yoloworld:latest" | ||
|
||
image = imgviz.io.imread(here / "_data" / "dogs.jpg") | ||
request: types.GenerateRequest = types.GenerateRequest( | ||
model=model, image=image, prompt=types.Prompt(texts=["dog"]) | ||
) | ||
response: types.GenerateResponse = apis.generate(request=request) | ||
|
||
assert response.model == model | ||
|
||
assert len(response.annotations) == 3 | ||
for annotation in response.annotations: | ||
assert annotation.bounding_box is not None | ||
assert annotation.text == "dog" | ||
assert isinstance(annotation.score, float) | ||
assert annotation.mask is None |