Repository navigation
[Pipelines] Add DreamLite text-to-image and image-edit pipelines #13815
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
Merged
dg845
merged 21 commits into
huggingface:main
from
Carlofkl:feature/dreamlite-integration
Jun 12, 2026
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d9e9b9b
feat(pipelines): add DreamLite text-to-image and image-edit pipelines
Carlofkl 7bce36f
docs+tests(pipelines/dreamlite): pin Hub repos to `diffusers` branch
Carlofkl 4fb57d9
chore(pipelines/dreamlite): sync `# Copied from` blocks + dummy objec…
Carlofkl 0b7d747
Merge branch 'main' into feature/dreamlite-integration
yiyixuxu 032412c
docs(dreamlite): register attention processor + split combined docstr…
Carlofkl 7d9bd46
Merge branch 'main' into feature/dreamlite-integration
sayakpaul 62a5db6
refactor(dreamlite): address review feedback from #13815
Carlofkl 9eff43b
Merge branch 'main' into feature/dreamlite-integration
dg845 9fd711a
refactor(dreamlite): address dg845 follow-up review
Carlofkl 6330425
fix(dreamlite): correct Q/K/V layout for dispatch_attention_fn
Carlofkl 0d952dd
Merge branch 'main' into feature/dreamlite-integration
dg845 b39e672
test(dreamlite): swap MagicMock for tiny real Qwen3-VL fixture
Carlofkl 9c65935
Merge branch 'main' into feature/dreamlite-integration
dg845 654043a
Apply style fixes
github-actions[bot] 4fdf73a
Merge branch 'main' into feature/dreamlite-integration
dg845 6653dd4
fix(dreamlite): address blocking review issues from #13815
Carlofkl a02bb23
fix(dreamlite): forward all processor outputs to Qwen3VL text encoder
Carlofkl 71f65e2
Apply style fixes
github-actions[bot] b7ef0f9
Merge branch 'main' into feature/dreamlite-integration
dg845 f38937d
docs(dreamlite): address final review nits from #13815
Carlofkl 67279bb
Merge branch 'main' into feature/dreamlite-integration
dg845 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| <!--Copyright 2026 The ByteDance Authors. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. | ||
| --> | ||
|
|
||
| # DreamLite | ||
|
|
||
| DreamLite is a text-to-image and image-editing model from ByteDance. It pairs a custom 2D U-Net | ||
| (`DreamLiteUNetModel`) with the `Qwen3-VL` multimodal encoder as its prompt / image-instruction encoder, | ||
| and uses an `AutoencoderTiny` (TAESD-style) VAE for fast latent encode/decode. | ||
|
|
||
| Two pipelines are exposed: | ||
|
|
||
| | Pipeline | Modes | CFG | Use case | | ||
| |---|---|---|---| | ||
| | [`DreamLitePipeline`] | text-to-image **and** image-editing (auto-selected by whether `image` is `None`) | 3-branch dual CFG (`guidance_scale` on text branch, `image_guidance_scale` on image branch, à la InstructPix2Pix) | Highest quality | | ||
| | [`DreamLiteMobilePipeline`] | text-to-image **and** image-editing (auto-selected by whether `image` is `None`) | None — distilled, single UNet forward per step | On-device / low-latency | | ||
|
|
||
| Official checkpoints: | ||
|
|
||
| * Base model: [carlofkl/DreamLite-base](https://huggingface.co/carlofkl/DreamLite-base) | ||
| * Distilled mobile model: [carlofkl/DreamLite-mobile](https://huggingface.co/carlofkl/DreamLite-mobile) | ||
|
|
||
| > [!TIP] | ||
| > Both pipelines auto-detect text-to-image vs. image-editing mode from whether the `image` argument is | ||
| > provided. There is no separate `Img2Img` class. | ||
|
|
||
| > [!TIP] | ||
| > When loading an input image for editing, prefer `diffusers.utils.load_image(...)` over raw `PIL.Image.open(...)`. | ||
| > `load_image` enforces an RGB conversion and applies EXIF orientation, both of which the pipeline assumes. | ||
| > A plain `Image.open` of an RGBA / palette / EXIF-rotated source will silently produce a different latent | ||
| > conditioning and degrade output quality. | ||
|
|
||
| ## Text-to-image (Base) | ||
|
|
||
| ```python | ||
| import torch | ||
| from diffusers import DreamLitePipeline | ||
|
|
||
| pipe = DreamLitePipeline.from_pretrained("carlofkl/DreamLite-base", revision="diffusers", torch_dtype=torch.bfloat16) | ||
| pipe = pipe.to("cuda") | ||
|
|
||
| image = pipe( | ||
| prompt="a dog running on the grass", | ||
| negative_prompt="", | ||
| height=1024, | ||
| width=1024, | ||
| num_inference_steps=28, | ||
| guidance_scale=3.5, | ||
| generator=torch.Generator("cpu").manual_seed(42), | ||
| ).images[0] | ||
| image.save("dreamlite_t2i.png") | ||
| ``` | ||
|
|
||
| ## Image editing (Base) | ||
|
|
||
| Pass an `image` to enter edit mode. Both `guidance_scale` (text branch) and `image_guidance_scale` | ||
| (image branch) are active here. | ||
|
|
||
| ```python | ||
| import torch | ||
| from diffusers import DreamLitePipeline | ||
| from diffusers.utils import load_image | ||
|
|
||
| pipe = DreamLitePipeline.from_pretrained("carlofkl/DreamLite-base", revision="diffusers", torch_dtype=torch.bfloat16) | ||
| pipe = pipe.to("cuda") | ||
|
|
||
| source = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cat.png") | ||
|
|
||
| image = pipe( | ||
| prompt="turn the cat into a corgi", | ||
| image=source, | ||
| height=1024, | ||
| width=1024, | ||
| num_inference_steps=28, | ||
| guidance_scale=3.5, | ||
| image_guidance_scale=1.5, | ||
|
dg845 marked this conversation as resolved.
Outdated
|
||
| generator=torch.Generator("cpu").manual_seed(42), | ||
| ).images[0] | ||
| image.save("dreamlite_edit.png") | ||
| ``` | ||
|
|
||
| ## Text-to-image (Mobile) | ||
|
|
||
| The mobile pipeline is distilled and skips CFG entirely — a single UNet forward per step. It accepts the | ||
| same `prompt` / `height` / `width` / `num_inference_steps` arguments, but **ignores** `guidance_scale` and | ||
| `image_guidance_scale` if passed (a warning is logged). | ||
|
|
||
| ```python | ||
| import torch | ||
| from diffusers import DreamLiteMobilePipeline | ||
|
|
||
| pipe = DreamLiteMobilePipeline.from_pretrained("carlofkl/DreamLite-mobile", revision="diffusers", torch_dtype=torch.bfloat16) | ||
| pipe = pipe.to("cuda") | ||
|
|
||
| image = pipe( | ||
| prompt="a dog running on the grass", | ||
| height=1024, | ||
| width=1024, | ||
| num_inference_steps=4, | ||
| generator=torch.Generator("cpu").manual_seed(42), | ||
| ).images[0] | ||
| image.save("dreamlite_mobile_t2i.png") | ||
| ``` | ||
|
|
||
| ## Image editing (Mobile) | ||
|
|
||
| ```python | ||
| import torch | ||
| from diffusers import DreamLiteMobilePipeline | ||
| from diffusers.utils import load_image | ||
|
|
||
| pipe = DreamLiteMobilePipeline.from_pretrained("carlofkl/DreamLite-mobile", revision="diffusers", torch_dtype=torch.bfloat16) | ||
| pipe = pipe.to("cuda") | ||
|
|
||
| source = load_image("https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/cat.png") | ||
|
dg845 marked this conversation as resolved.
Outdated
|
||
|
|
||
| image = pipe( | ||
| prompt="turn the cat into a corgi", | ||
| image=source, | ||
| height=1024, | ||
| width=1024, | ||
| num_inference_steps=4, | ||
| generator=torch.Generator("cpu").manual_seed(42), | ||
| ).images[0] | ||
| image.save("dreamlite_mobile_edit.png") | ||
| ``` | ||
|
|
||
| ## Notes and limitations | ||
|
|
||
| * Both pipelines force `batch_size = 1` internally; `num_images_per_prompt` controls how many samples | ||
| are drawn from the same prompt rather than parallel batching. | ||
| * The prompt encoder is `Qwen3-VL`, which is a multimodal model. Loading the full pipeline therefore | ||
| requires sufficient GPU memory for both the U-Net and the Qwen3-VL text encoder (~4 GB + ~0.7 GB | ||
| in bf16 for the base release). | ||
| * The VAE is `AutoencoderTiny` and exposes `encoder_block_out_channels`; `vae_scale_factor` is derived | ||
| from it at pipeline init time. | ||
|
|
||
| ## DreamLitePipeline | ||
|
|
||
| [[autodoc]] DreamLitePipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## DreamLiteMobilePipeline | ||
|
|
||
| [[autodoc]] DreamLiteMobilePipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## DreamLitePipelineOutput | ||
|
|
||
| [[autodoc]] pipelines.dreamlite.pipeline_output.DreamLitePipelineOutput | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.