Skip to content

Commit 0be8d16

Browse files
committed
feat(tests): 🧪 Introduce auto seg tests
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
1 parent 1584763 commit 0be8d16

5 files changed

Lines changed: 79 additions & 1 deletion

File tree

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Install Test Python
2+
name: Install and pytest test
33
on: [push, pull_request, workflow_dispatch]
44

55
jobs:
@@ -44,6 +44,12 @@ jobs:
4444
source venv/bin/activate
4545
poetry install
4646
47+
- name: Pytest test
48+
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
49+
run: |
50+
source venv/bin/activate
51+
pytest .
52+
4753
4854
- name: Set up a virtual environment
4955
if: matrix.os == 'windows-latest'
@@ -73,3 +79,10 @@ jobs:
7379
run: |
7480
.\venv\Scripts\Activate.ps1
7581
poetry install
82+
83+
- name: Pytest test
84+
shell: pwsh
85+
if: matrix.os == 'windows-latest'
86+
run: |
87+
.\venv\Scripts\Activate.ps1
88+
pytest .

tests/images/dog.jpg

97.5 KB
Loading

tests/images/groceries.jpg

164 KB
Loading

tests/images/truck.jpg

265 KB
Loading

tests/test_image_seg_auto_mask.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Test image segmentation with automatic mask prediction."""
2+
3+
from cv2 import COLOR_BGR2RGB
4+
from cv2 import cvtColor as cv_cvtColor
5+
from cv2 import imread as cv_imread
6+
7+
from metaseg import SegAutoMaskPredictor
8+
9+
10+
def test_seg_auto_mask_vit_l() -> None:
11+
"""Test test_seg_auto_mask_vit_l function."""
12+
SegAutoMaskPredictor().image_predict(
13+
source="tests/images/dog.jpg",
14+
model_type="vit_l", # vit_l, vit_h, vit_b
15+
points_per_side=16,
16+
points_per_batch=64,
17+
min_area=0,
18+
output_path="output.jpg",
19+
show=False,
20+
save=False,
21+
)
22+
23+
24+
def test_seg_auto_mask_vit_b() -> None:
25+
"""Test test_seg_auto_mask_vit_b function."""
26+
SegAutoMaskPredictor().image_predict(
27+
source="tests/images/truck.jpg",
28+
model_type="vit_b", # vit_l, vit_h, vit_b
29+
points_per_side=16,
30+
points_per_batch=64,
31+
min_area=0,
32+
output_path="output.jpg",
33+
show=False,
34+
save=False,
35+
)
36+
37+
38+
def test_seg_auto_mask_vit_h() -> None:
39+
"""Test test_seg_auto_mask_vit_h function."""
40+
SegAutoMaskPredictor().image_predict(
41+
source="tests/images/groceries.jpg",
42+
model_type="vit_h", # vit_l, vit_h, vit_b
43+
points_per_side=16,
44+
points_per_batch=64,
45+
min_area=0,
46+
output_path="output.jpg",
47+
show=False,
48+
save=False,
49+
)
50+
51+
52+
def test_cv_seg_auto_mask_vit_l() -> None:
53+
"""Test test_cv_seg_auto_mask_vit_l function."""
54+
image = cv_imread("tests/images/truck.jpg")
55+
image = cv_cvtColor(image, COLOR_BGR2RGB)
56+
SegAutoMaskPredictor().image_predict(
57+
source=image,
58+
model_type="vit_l", # vit_l, vit_h, vit_b
59+
points_per_side=16,
60+
points_per_batch=64,
61+
min_area=0,
62+
output_path="output.jpg",
63+
show=False,
64+
save=False,
65+
)

0 commit comments

Comments
 (0)