Skip to content

Commit

Permalink
implement img2img test
Browse files Browse the repository at this point in the history
  • Loading branch information
hugohonda committed Oct 18, 2024
1 parent 7ac16db commit a0b8bad
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/models/test_flux1.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ def test_fail_image_generation_dimensions(model):
seed=42,
)
except ValueError as e:
assert (
str(e)
== f"`height` and `width` have to be divisible by 8 but are {height} and {width}."
)
assert str(e) == "height and width must be multiples of 8."


def test_fail_image_mask_size(model):
Expand Down Expand Up @@ -144,6 +141,28 @@ def test_multiple_images_per_prompt(model):
assert image.size == (32, 32)


def test_image_to_image(model):
prompt = "pixar style"
image = Image.open("tests/shared_data/images/chihuahua.png")

result = model(
task=Flux1Task.IMAGE_TO_IMAGE,
prompt=prompt,
image=image,
height=32,
width=32,
num_inference_steps=1,
guidance_scale=0.5,
seed=42,
)

assert result is not None
assert len(result) == 1
image = result[0]
assert image.mode == "RGB"
assert image.size == (32, 32)


@pytest.fixture(scope="session")
def model():
return Flux1()

0 comments on commit a0b8bad

Please sign in to comment.