Skip to content
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

Deprecate _img_open #471

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fallback-version = '0.0.0'
[tool.rye]
managed = true
dev-dependencies = [
"pyright==1.1.372",
"pyright==1.1.384",
"docformatter>=1.7.5",
"pytest>=8.0.0",
"coverage>=7.4.1",
Expand Down
126 changes: 61 additions & 65 deletions tests/e2e/test_diffusion.py

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions tests/e2e/test_doc_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
from refiners.foundationals.latent_diffusion.stable_diffusion_xl.model import StableDiffusion_XL


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(autouse=True)
def ensure_gc():
# Avoid GPU OOMs
Expand Down Expand Up @@ -51,27 +47,27 @@ def sdxl(

@pytest.fixture
def image_prompt_german_castle(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "german-castle.jpg").convert("RGB")
return Image.open(ref_path / "german-castle.jpg").convert("RGB")


@pytest.fixture
def expected_image_guide_adapting_sdxl_vanilla(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_image_guide_adapting_sdxl_vanilla.png").convert("RGB")
return Image.open(ref_path / "expected_image_guide_adapting_sdxl_vanilla.png").convert("RGB")


@pytest.fixture
def expected_image_guide_adapting_sdxl_single_lora(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_image_guide_adapting_sdxl_single_lora.png").convert("RGB")
return Image.open(ref_path / "expected_image_guide_adapting_sdxl_single_lora.png").convert("RGB")


@pytest.fixture
def expected_image_guide_adapting_sdxl_multiple_loras(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_image_guide_adapting_sdxl_multiple_loras.png").convert("RGB")
return Image.open(ref_path / "expected_image_guide_adapting_sdxl_multiple_loras.png").convert("RGB")


@pytest.fixture
def expected_image_guide_adapting_sdxl_loras_ip_adapter(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_image_guide_adapting_sdxl_loras_ip_adapter.png").convert("RGB")
return Image.open(ref_path / "expected_image_guide_adapting_sdxl_loras_ip_adapter.png").convert("RGB")


@no_grad()
Expand Down
10 changes: 3 additions & 7 deletions tests/e2e/test_lcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
from refiners.foundationals.latent_diffusion.stable_diffusion_xl.model import StableDiffusion_XL


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(autouse=True)
def ensure_gc():
# Avoid GPU OOMs
Expand All @@ -33,17 +29,17 @@ def ref_path(test_e2e_path: Path) -> Path:

@pytest.fixture
def expected_lcm_base(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lcm_base.png").convert("RGB")
return Image.open(ref_path / "expected_lcm_base.png").convert("RGB")


@pytest.fixture
def expected_lcm_lora_1_0(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lcm_lora_1_0.png").convert("RGB")
return Image.open(ref_path / "expected_lcm_lora_1_0.png").convert("RGB")


@pytest.fixture
def expected_lcm_lora_1_2(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lcm_lora_1_2.png").convert("RGB")
return Image.open(ref_path / "expected_lcm_lora_1_2.png").convert("RGB")


@no_grad()
Expand Down
10 changes: 3 additions & 7 deletions tests/e2e/test_lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
from refiners.foundationals.latent_diffusion.stable_diffusion_xl.model import StableDiffusion_XL


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(autouse=True)
def ensure_gc():
# Avoid GPU OOMs
Expand All @@ -32,17 +28,17 @@ def ref_path(test_e2e_path: Path) -> Path:

@pytest.fixture
def expected_lightning_base_4step(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lightning_base_4step.png").convert("RGB")
return Image.open(ref_path / "expected_lightning_base_4step.png").convert("RGB")


@pytest.fixture
def expected_lightning_base_1step(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lightning_base_1step.png").convert("RGB")
return Image.open(ref_path / "expected_lightning_base_1step.png").convert("RGB")


@pytest.fixture
def expected_lightning_lora_4step(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_lightning_lora_4step.png").convert("RGB")
return Image.open(ref_path / "expected_lightning_lora_4step.png").convert("RGB")


@no_grad()
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/test_mvanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
from refiners.foundationals.swin.mvanet import MVANet


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(scope="module")
def ref_path(test_e2e_path: Path) -> Path:
return test_e2e_path / "test_mvanet_ref"


@pytest.fixture(scope="module")
def ref_cactus(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "cactus.png").convert("RGB")
return Image.open(ref_path / "cactus.png").convert("RGB")


@pytest.fixture
def expected_cactus_mask(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_cactus_mask.png")
return Image.open(ref_path / "expected_cactus_mask.png")


@pytest.fixture
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/test_preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@
from refiners.foundationals.latent_diffusion.preprocessors.informative_drawings import InformativeDrawings


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(scope="module")
def diffusion_ref_path(test_e2e_path: Path) -> Path:
return test_e2e_path / "test_diffusion_ref"


@pytest.fixture(scope="module")
def cutecat_init(diffusion_ref_path: Path) -> Image.Image:
return _img_open(diffusion_ref_path / "cutecat_init.png").convert("RGB")
return Image.open(diffusion_ref_path / "cutecat_init.png").convert("RGB")


@pytest.fixture
def expected_image_informative_drawings(diffusion_ref_path: Path) -> Image.Image:
return _img_open(diffusion_ref_path / "cutecat_guide_lineart.png").convert("RGB")
return Image.open(diffusion_ref_path / "cutecat_guide_lineart.png").convert("RGB")


@pytest.fixture
Expand Down
12 changes: 4 additions & 8 deletions tests/e2e/test_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,29 @@
from refiners.solutions import BoxSegmenter


def _img_open(path: Path) -> Image.Image:
return Image.open(path) # type: ignore


@pytest.fixture(scope="module")
def ref_path(test_e2e_path: Path) -> Path:
return test_e2e_path / "test_solutions_ref"


@pytest.fixture(scope="module")
def ref_shelves(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "shelves.jpg").convert("RGB")
return Image.open(ref_path / "shelves.jpg").convert("RGB")


@pytest.fixture
def expected_box_segmenter_plant_mask(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_box_segmenter_plant_mask.png")
return Image.open(ref_path / "expected_box_segmenter_plant_mask.png")


@pytest.fixture
def expected_box_segmenter_spray_mask(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_box_segmenter_spray_mask.png")
return Image.open(ref_path / "expected_box_segmenter_spray_mask.png")


@pytest.fixture
def expected_box_segmenter_spray_cropped_mask(ref_path: Path) -> Image.Image:
return _img_open(ref_path / "expected_box_segmenter_spray_cropped_mask.png")
return Image.open(ref_path / "expected_box_segmenter_spray_cropped_mask.png")


def test_box_segmenter(
Expand Down