From 8712440929234d9ecc6b1b7dad0480190be6e027 Mon Sep 17 00:00:00 2001 From: stevhliu Date: Tue, 17 Feb 2026 13:47:08 -0800 Subject: [PATCH 1/2] add example --- docs/source/en/api/pipelines/qwenimage.md | 48 ++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/source/en/api/pipelines/qwenimage.md b/docs/source/en/api/pipelines/qwenimage.md index ee3dd3b28e4d..e81464c76de5 100644 --- a/docs/source/en/api/pipelines/qwenimage.md +++ b/docs/source/en/api/pipelines/qwenimage.md @@ -29,7 +29,7 @@ Qwen-Image comes in the following variants: | Qwen-Image-Edit Plus | [Qwen/Qwen-Image-Edit-2509](https://huggingface.co/Qwen/Qwen-Image-Edit-2509) | > [!TIP] -> [Caching](../../optimization/cache) may also speed up inference by storing and reusing intermediate outputs. +> See the [Caching](../../optimization/cache) guide to speed up inference by storing and reusing intermediate outputs. ## LoRA for faster inference @@ -91,6 +91,46 @@ image.save("qwen_fewsteps.png") > [!TIP] > The `guidance_scale` parameter in the pipeline is there to support future guidance-distilled models when they come up. Note that passing `guidance_scale` to the pipeline is ineffective. To enable classifier-free guidance, please pass `true_cfg_scale` and `negative_prompt` (even an empty negative prompt like " ") should enable classifier-free guidance computations. +## Decomposing an image with QwenImageLayeredPipeline + +[`QwenImageLayeredPipeline`] decomposes an image into multiple RGBA layers, so you can edit each layer independently without affecting the others. + +```py +from diffusers import QwenImageLayeredPipeline +from PIL import Image +from io import BytesIO +import torch +import requests + +pipeline = QwenImageLayeredPipeline.from_pretrained("Qwen/Qwen-Image-Layered") +pipeline = pipeline.to("cuda", torch.bfloat16) +pipeline.set_progress_bar_config(disable=None) + +image_url = "https://www.pngkey.com/png/detail/620-6208835_walmart-regular-show-cereal-box-png-walmart-regular.png" +response = requests.get(image_url) +image = Image.open(BytesIO(response.content)).convert("RGBA") +inputs = { + "image": image, + "generator": torch.Generator(device='cuda').manual_seed(777), + "true_cfg_scale": 4.0, + "negative_prompt": " ", + "num_inference_steps": 50, + "num_images_per_prompt": 1, + "layers": 4, + "resolution": 640, + "cfg_normalize": True, + "use_en_prompt": True, +} + +with torch.inference_mode(): + output = pipeline(**inputs) + output_image = output.images[0] + +for i, image in enumerate(output_image): + image.save(f"{i}.png") + +``` + ## Multi-image reference with QwenImageEditPlusPipeline With [`QwenImageEditPlusPipeline`], one can provide multiple images as input reference. @@ -190,6 +230,12 @@ For detailed benchmark scripts and results, see [this gist](https://gist.github. - all - __call__ +## QwenImageLayeredPipeline + +[[autodoc]] QwenImageLayeredPipeline + - all + - __call__ + ## QwenImagePipelineOutput [[autodoc]] pipelines.qwenimage.pipeline_output.QwenImagePipelineOutput \ No newline at end of file From d65a263017becf62417229e12c6777c2ef1e8aab Mon Sep 17 00:00:00 2001 From: stevhliu Date: Wed, 18 Feb 2026 10:50:43 -0800 Subject: [PATCH 2/2] feedback --- docs/source/en/api/pipelines/qwenimage.md | 40 ----------------------- 1 file changed, 40 deletions(-) diff --git a/docs/source/en/api/pipelines/qwenimage.md b/docs/source/en/api/pipelines/qwenimage.md index e81464c76de5..c0994c8685d0 100644 --- a/docs/source/en/api/pipelines/qwenimage.md +++ b/docs/source/en/api/pipelines/qwenimage.md @@ -91,46 +91,6 @@ image.save("qwen_fewsteps.png") > [!TIP] > The `guidance_scale` parameter in the pipeline is there to support future guidance-distilled models when they come up. Note that passing `guidance_scale` to the pipeline is ineffective. To enable classifier-free guidance, please pass `true_cfg_scale` and `negative_prompt` (even an empty negative prompt like " ") should enable classifier-free guidance computations. -## Decomposing an image with QwenImageLayeredPipeline - -[`QwenImageLayeredPipeline`] decomposes an image into multiple RGBA layers, so you can edit each layer independently without affecting the others. - -```py -from diffusers import QwenImageLayeredPipeline -from PIL import Image -from io import BytesIO -import torch -import requests - -pipeline = QwenImageLayeredPipeline.from_pretrained("Qwen/Qwen-Image-Layered") -pipeline = pipeline.to("cuda", torch.bfloat16) -pipeline.set_progress_bar_config(disable=None) - -image_url = "https://www.pngkey.com/png/detail/620-6208835_walmart-regular-show-cereal-box-png-walmart-regular.png" -response = requests.get(image_url) -image = Image.open(BytesIO(response.content)).convert("RGBA") -inputs = { - "image": image, - "generator": torch.Generator(device='cuda').manual_seed(777), - "true_cfg_scale": 4.0, - "negative_prompt": " ", - "num_inference_steps": 50, - "num_images_per_prompt": 1, - "layers": 4, - "resolution": 640, - "cfg_normalize": True, - "use_en_prompt": True, -} - -with torch.inference_mode(): - output = pipeline(**inputs) - output_image = output.images[0] - -for i, image in enumerate(output_image): - image.save(f"{i}.png") - -``` - ## Multi-image reference with QwenImageEditPlusPipeline With [`QwenImageEditPlusPipeline`], one can provide multiple images as input reference.