-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Add StableDiffusion3InstructPix2PixPipeline #11378
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
+1,314
−1
Merged
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
f90adbb
upload StableDiffusion3InstructPix2PixPipeline
xduzhangjiayu 94be186
Merge branch 'huggingface:main' into sd3_p2p
xduzhangjiayu 296a86e
Merge branch 'main' into sd3_p2p
xduzhangjiayu 07fd208
Merge branch 'main' into sd3_p2p
xduzhangjiayu 7b5bffa
Merge branch 'main' into sd3_p2p
xduzhangjiayu d5a7542
Merge branch 'main' into sd3_p2p
xduzhangjiayu 8adeab8
Merge branch 'main' into sd3_p2p
xduzhangjiayu d6f72d8
Merge branch 'main' into sd3_p2p
xduzhangjiayu 055d3bb
Move to community
xduzhangjiayu 5068384
Add readme
xduzhangjiayu 912027c
Fix images
xduzhangjiayu 194082e
remove images
xduzhangjiayu d9be254
Change image url
xduzhangjiayu 8ca42e7
Merge branch 'main' into sd3_p2p
asomoza ec55dbe
fix
xduzhangjiayu e67c57f
Merge branch 'sd3_p2p' of https://github.com/xduzhangjiayu/diffusers …
xduzhangjiayu 0df2130
Merge branch 'main' into sd3_p2p
xduzhangjiayu 1537115
Apply style fixes
github-actions[bot] 9735713
Merge branch 'main' into sd3_p2p
asomoza 95b2af1
Merge branch 'main' into sd3_p2p
xduzhangjiayu c8dc6f1
Merge branch 'main' into sd3_p2p
xduzhangjiayu 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -86,6 +86,7 @@ PIXART-α Controlnet pipeline | Implementation of the controlnet model for pixar | |||||||||||||
| | Perturbed-Attention Guidance |StableDiffusionPAGPipeline is a modification of StableDiffusionPipeline to support Perturbed-Attention Guidance (PAG).|[Perturbed-Attention Guidance](#perturbed-attention-guidance)|[Notebook](https://github.com/huggingface/notebooks/blob/main/diffusers/perturbed_attention_guidance.ipynb)|[Hyoungwon Cho](https://github.com/HyoungwonCho)| | ||||||||||||||
| | CogVideoX DDIM Inversion Pipeline | Implementation of DDIM inversion and guided attention-based editing denoising process on CogVideoX. | [CogVideoX DDIM Inversion Pipeline](#cogvideox-ddim-inversion-pipeline) | - | [LittleNyima](https://github.com/LittleNyima) | | ||||||||||||||
| | FaithDiff Stable Diffusion XL Pipeline | Implementation of [(CVPR 2025) FaithDiff: Unleashing Diffusion Priors for Faithful Image Super-resolutionUnleashing Diffusion Priors for Faithful Image Super-resolution](https://arxiv.org/abs/2411.18824) - FaithDiff is a faithful image super-resolution method that leverages latent diffusion models by actively adapting the diffusion prior and jointly fine-tuning its components (encoder and diffusion model) with an alignment module to ensure high fidelity and structural consistency. | [FaithDiff Stable Diffusion XL Pipeline](#faithdiff-stable-diffusion-xl-pipeline) | [](https://huggingface.co/jychen9811/FaithDiff) | [Junyang Chen, Jinshan Pan, Jiangxin Dong, IMAG Lab, (Adapted by Eliseu Silva)](https://github.com/JyChen9811/FaithDiff) | | ||||||||||||||
| | Stable Diffusion 3 InstructPix2Pix Pipeline | Implementation of Stable Diffusion 3 InstructPix2Pix Pipeline | [Stable Diffusion 3 InstructPix2Pix Pipeline](#stable-diffusion-3-instructpix2pix-pipeline) | [![Hugging Face Models]()](https://huggingface.co/BleachNick/SD3_UltraEdit_freeform) [![Hugging Face Models]()](https://huggingface.co/CaptainZZZ/sd3-instructpix2pix) | [Jiayu Zhang](https://github.com/xduzhangjiayu) and [Haozhe Zhao](https://github.com/HaozheZhao)| | ||||||||||||||
| To load a custom pipeline you just need to pass the `custom_pipeline` argument to `DiffusionPipeline`, as one of the files in `diffusers/examples/community`. Feel free to send a PR with your own pipelines, we will merge them quickly. | ||||||||||||||
|
|
||||||||||||||
| ```py | ||||||||||||||
|
|
@@ -5432,4 +5433,50 @@ cropped_image = gen_image.crop((0, 0, width_init, height_init)) | |||||||||||||
| cropped_image.save("data/result.png") | ||||||||||||||
| ```` | ||||||||||||||
| ### Result | ||||||||||||||
| [<img src="https://huggingface.co/datasets/DEVAIEXP/assets/resolve/main/faithdiff_restored.PNG" width="512px" height="512px"/>](https://imgsli.com/MzY1NzE2) | ||||||||||||||
| [<img src="https://huggingface.co/datasets/DEVAIEXP/assets/resolve/main/faithdiff_restored.PNG" width="512px" height="512px"/>](https://imgsli.com/MzY1NzE2) | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| # Stable Diffusion 3 InstructPix2Pix Pipeline | ||||||||||||||
| This the implementation of the Stable Diffusion 3 InstructPix2Pix Pipeline, based on the HuggingFace Diffusers. | ||||||||||||||
|
|
||||||||||||||
| ## Example Usage | ||||||||||||||
| This pipeline aims to edit image based on user's instruction by using SD3 | ||||||||||||||
| ````py | ||||||||||||||
| import torch | ||||||||||||||
| from diffusers import SD3Transformer2DModel | ||||||||||||||
| from diffusers import DiffusionPipeline | ||||||||||||||
| from diffusers.utils import load_image | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| resolution = 512 | ||||||||||||||
| image = load_image("https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png").resize( | ||||||||||||||
| (resolution, resolution) | ||||||||||||||
| ) | ||||||||||||||
| edit_instruction = "Turn sky into a sunny one" | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| pipe = DiffusionPipeline.from_pretrained( | ||||||||||||||
| "stabilityai/stable-diffusion-3-medium-diffusers", custom_pipeline="pipeline_stable_diffusion_3_instruct_pix2pix", torch_dtype=torch.float16).to('cuda') | ||||||||||||||
|
|
||||||||||||||
| pipe.transformer = SD3Transformer2DModel.from_pretrained("CaptainZZZ/sd3-instructpix2pix",torch_dtype=torch.float16).to('cuda') | ||||||||||||||
|
|
||||||||||||||
| edited_image = pipe( | ||||||||||||||
| prompt=edit_instruction, | ||||||||||||||
| image=image, | ||||||||||||||
| height=resolution, | ||||||||||||||
| width=resolution, | ||||||||||||||
| guidance_scale=7.5, | ||||||||||||||
| image_guidance_scale=1.5, | ||||||||||||||
| num_inference_steps=30, | ||||||||||||||
| ).images[0] | ||||||||||||||
|
|
||||||||||||||
| edited_image.save("edited_image.png") | ||||||||||||||
| ```` | ||||||||||||||
| ### Result | ||||||||||||||
|  | ||||||||||||||
|  | ||||||||||||||
|
||||||||||||||
| ### Result | |
|  | |
|  | |
| |Original|Edited| | |
| |---|---| | |
| || |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.