Skip to content

Commit

Permalink
replace tests format coco with camvid
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslavknotek committed Jan 24, 2025
1 parent 68d2735 commit fd1bcb8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
36 changes: 36 additions & 0 deletions tests/python/sdk/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ def fxt_login(admin_user: str, restore_db_per_class):
yield (client, user)


@pytest.fixture
def fxt_camvid_dataset(tmp_path: Path):
img_path = tmp_path / "img.png"
with img_path.open("wb") as f:
f.write(generate_image_file(filename=str(img_path), size=(5, 10)).getvalue())

annot_path = tmp_path / "annot.png"
r,g,b = (127,0,0)
annot = generate_image_file(
filename=str(annot_path),
size=(5, 10),
color=(r, g, b),
).getvalue()
with annot_path.open("wb") as f:
f.write(annot)

label_colors_path = tmp_path / "label_colors.txt"
with open(label_colors_path, "w") as f:
f.write(f"{r} {g} {b} ROI\n")

dataset_img_path = "default/img.png"
dataset_annot_path = "default/annot.png"
default_txt_path = tmp_path / "default.txt"
with open(default_txt_path, "w") as f:
f.write(f"{dataset_img_path} {dataset_annot_path}")

dataset_path = tmp_path / "camvid_dataset.zip"
with ZipFile(dataset_path, "x") as f:
f.write(img_path, arcname=dataset_img_path)
f.write(annot_path, arcname=dataset_annot_path)
f.write(default_txt_path, arcname="default.txt")
f.write(label_colors_path, arcname="label_colors.txt")

yield dataset_path


@pytest.fixture
def fxt_coco_dataset(tmp_path: Path, fxt_image_file: Path, fxt_coco_file: Path):
dataset_path = tmp_path / "coco_dataset.zip"
Expand Down
8 changes: 4 additions & 4 deletions tests/python/sdk/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ def test_can_create_project_from_dataset(self, fxt_coco_dataset: Path):

@pytest.mark.parametrize("convert", [True, False])
def test_can_create_project_from_dataset_with_polygons_to_masks_param(
self, fxt_coco_dataset: Path, convert: bool
self, fxt_camvid_dataset: Path, convert: bool
):
pbar_out = io.StringIO()
pbar = make_pbar(file=pbar_out)

project = self.client.projects.create_from_dataset(
spec=models.ProjectWriteRequest(name="project with data"),
dataset_path=fxt_coco_dataset,
dataset_format="COCO 1.0",
conv_mask_to_poly=False,
dataset_path=fxt_camvid_dataset,
dataset_format="Camvid 1.0",
conv_mask_to_poly=convert,
pbar=pbar,
)

Expand Down

0 comments on commit fd1bcb8

Please sign in to comment.