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

Diffusers: Simplified the README files. Updated CI tests. #1718

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
22 changes: 0 additions & 22 deletions examples/stable-diffusion/README_legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,28 +316,6 @@ python image_to_image_generation.py \
--bf16
```

### FLUX.1 Image-to-Image

Here is how to generate a FLUX.1 image using a single input image and prompt:

```bash
python image_to_image_generation.py \
--model_name_or_path "black-forest-labs/FLUX.1-dev" \
--src_image_path "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png" \
--prompts "cat wizard, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney, 8k" \
--num_images_per_prompt 10 \
--batch_size 1 \
--strength 0.9 \
--guidance_scale 3.5 \
--num_inference_steps 30 \
--image_save_dir /tmp/flux_images \
--use_habana \
--use_hpu_graphs \
--gaudi_config Habana/stable-diffusion \
--sdp_on_bf16 \
--bf16
```

### Stable Diffusion Image Variations

Here is how to generate image variations of a single image (without any input prompts):
Expand Down
17 changes: 17 additions & 0 deletions tests/test_diffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ def check_8xhpu(test_case):
return pytest.mark.skipif(skip, reason="test requires 8xHPU multi-card system")(test_case)


def legacy(test_case):
"""
Decorator skipping a test if it's old
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decorator used to skip tests for legacy models

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 2c4e06e

"""
skip = os.environ.get("RUN_DIFFUSERS_LEGACY", "0") != "1"
return pytest.mark.skipif(skip, reason="This test is for old/legacy mmodel. Skipped starting 1.16.0")(test_case)


class GaudiPipelineUtilsTester(TestCase):
"""
Tests the features added on top of diffusers/pipeline_utils.py.
Expand Down Expand Up @@ -622,6 +630,7 @@ def test_stable_diffusion_hpu_graphs(self):
self.assertEqual(images[-1].shape, (64, 64, 3))

@slow
@legacy
def test_no_throughput_regression_bf16(self):
prompts = [
"An image of a squirrel in Picasso style",
Expand Down Expand Up @@ -672,6 +681,7 @@ def test_no_throughput_regression_bf16(self):

@custom_bf16_ops
@slow
@legacy
def test_no_throughput_regression_autocast(self):
prompts = [
"An image of a squirrel in Picasso style",
Expand Down Expand Up @@ -705,6 +715,7 @@ def test_no_throughput_regression_autocast(self):

@custom_bf16_ops
@slow
@legacy
def test_no_generation_regression_ldm3d(self):
prompts = [
"An image of a squirrel in Picasso style",
Expand Down Expand Up @@ -795,6 +806,7 @@ def test_no_generation_regression_upscale(self):

@slow
@check_8xhpu
@legacy
def test_sd_textual_inversion(self):
path_to_script = (
Path(os.path.dirname(__file__)).parent
Expand Down Expand Up @@ -2324,6 +2336,7 @@ def test_depth2img_pipeline_hpu_graphs(self):
assert images[0].shape == (32, 32, 3)

@slow
@legacy
def test_depth2img_pipeline(self):
gaudi_config = GaudiConfig(use_torch_autocast=True)
model_name = "stabilityai/stable-diffusion-2-depth"
Expand Down Expand Up @@ -2464,6 +2477,7 @@ def test_script_train_controlnet(self):

@slow
@check_8xhpu
@legacy
def test_train_controlnet(self):
with tempfile.TemporaryDirectory() as tmpdir:
path_to_script = (
Expand Down Expand Up @@ -4879,6 +4893,7 @@ def test_inference_batch_single_identical(self):
super().test_inference_batch_single_identical(expected_max_diff=3e-3)

@slow
@legacy
def test_stable_diffusion_inpaint_no_throughput_regression(self):
"""Test that stable diffusion inpainting no throughput regression autocast"""

Expand Down Expand Up @@ -5668,6 +5683,7 @@ def test_ddpmpipline_hpu_graphs(self):
self.assertEqual(np.array(images[-1]).shape, (256, 256, 3))

@slow
@legacy
def test_no_throughput_regression_bf16(self):
batch_size = 16 # use batch size 16 as the baseline
model_name = "google/ddpm-ema-celebahq-256"
Expand Down Expand Up @@ -6009,6 +6025,7 @@ def test_flux_prompt_embeds(self):
@slow
@check_gated_model_access("black-forest-labs/FLUX.1-dev")
@pytest.mark.skipif(not IS_GAUDI2, reason="does not fit into Gaudi1 memory")
@legacy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove legacy for this test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 2c4e06e

def test_flux_img2img_inference(self):
repo_id = "black-forest-labs/FLUX.1-dev"
image_path = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png"
Expand Down