-
Notifications
You must be signed in to change notification settings - Fork 697
Added support for Stable Diffusion LCM model #15075
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
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b8aa6da
Added initial Stable diffusion LCM support
suryasidd 9ddd7f8
Added requirements
suryasidd 8fbae30
Added README
suryasidd f40e720
Fixed lintrunner issues
suryasidd 12a68f4
Added Intel license to main LICENSE file
suryasidd 301fcaa
Merge branch 'main' into stable_diffusion_lcm
suryasidd 6e85549
Fixed mypy issues
suryasidd c93afe0
Merge branch 'main' into stable_diffusion_lcm
suryasidd 0f09020
Separated load time from exec time
suryasidd 265d7dc
Decoupled model definition and backend lowering
suryasidd 3b50602
Updated License
suryasidd 5307368
Merge branch 'main' into stable_diffusion_lcm
suryasidd 3f349d3
Fixed linter issues
suryasidd 43b7bd1
Merge branch 'main' into stable_diffusion_lcm
suryasidd 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # Stable Diffusion LCM with OpenVINO Backend | ||
|
|
||
| This example demonstrates how to run Latent Consistency Models (LCM) for fast text-to-image generation on Intel hardware using ExecuTorch with the OpenVINO backend. | ||
|
|
||
| ## Overview | ||
|
|
||
| Latent Consistency Models (LCMs) are optimized diffusion models that generate high-quality images in just 4-8 steps, compared to 25-50 steps required by traditional Stable Diffusion models. This implementation: | ||
|
|
||
| ## Environment Setup | ||
| Follow the [instructions](../../../backends/openvino/README.md) of **Prerequisites** and **Setup** in `backends/openvino/README.md` to set up the OpenVINO backend. | ||
|
|
||
| ### Install dependencies | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| ## Export the Model | ||
|
|
||
| Export the LCM model: | ||
|
|
||
| ```bash | ||
| python export_lcm.py \ | ||
| --model_id SimianLuo/LCM_Dreamshaper_v7 \ | ||
| --output_dir ./lcm_models \ | ||
| --device CPU \ | ||
| --dtype fp16 | ||
| ``` | ||
| This will create three files in `./lcm_models/`: | ||
| - `text_encoder.pte` | ||
| - `unet.pte` | ||
| - `vae_decoder.pte` | ||
|
|
||
| ### Generate Images | ||
|
|
||
| Run inference with the exported model: | ||
|
|
||
| ```bash | ||
| python openvino_lcm.py \ | ||
| --models_dir ./lcm_models \ | ||
| --prompt "a beautiful sunset over mountains" \ | ||
| --steps 4 \ | ||
| --dtype fp16 | ||
| ``` | ||
| ## Supported Models | ||
|
|
||
| This implementation supports LCM-based Stable Diffusion models: | ||
| - **SimianLuo/LCM_Dreamshaper_v7** | ||
| - **latent-consistency/lcm-sdxl** | ||
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.