-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Community] PromptDiffusion Pipeline #6752
Merged
Merged
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
74bf30f
Create promptdiffusioncontrolnet.py
iczaw 57943e5
Update __init__.py
iczaw eb47987
Update __init__.py
iczaw d238058
Update promptdiffusioncontrolnet.py
iczaw 60c5266
Create pipeline_prompt_diffusion.py
iczaw 887bb28
Create convert_original_promptdiffusion_to_diffusers.py
iczaw fd0ef1c
Update convert_from_ckpt.py
iczaw 321ec2d
Update promptdiffusioncontrolnet.py
iczaw 5a04a26
Update pipeline_prompt_diffusion.py
iczaw 3b95ff6
Update README.md
iczaw a3444eb
Update pipeline_prompt_diffusion.py
iczaw daa5490
Delete src/diffusers/models/promptdiffusioncontrolnet.py
iczaw edda2a8
Update __init__.py
iczaw 9fa8d48
Update __init__.py
iczaw b8fcc55
Delete scripts/convert_original_promptdiffusion_to_diffusers.py
iczaw 288aabe
Update convert_from_ckpt.py
iczaw a20b904
Update README.md
iczaw 9f3534b
Delete examples/community/pipeline_prompt_diffusion.py
iczaw 0640e06
Create README.md
iczaw 9722e28
Create promptdiffusioncontrolnet.py
iczaw 1d463c8
Create convert_original_promptdiffusion_to_diffusers.py
iczaw 0ba43f8
Create pipeline_prompt_diffusion.py
iczaw 22f79a2
Update README.md
iczaw c545c6c
Update pipeline_prompt_diffusion.py
iczaw d9d63ef
Update README.md
iczaw 1ebbaf6
Update pipeline_prompt_diffusion.py
iczaw b81a23e
Update convert_original_promptdiffusion_to_diffusers.py
iczaw 0ec85a7
Update promptdiffusioncontrolnet.py
iczaw b6260af
Update README.md
iczaw c35b571
Merge branch 'main' into prompt-diffusion
sayakpaul 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 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,50 @@ | ||
# PromptDiffusion Pipeline | ||
|
||
From the project [page](https://zhendong-wang.github.io/prompt-diffusion.github.io/) | ||
|
||
"With a prompt consisting of a task-specific example pair of images and text guidance, and a new query image, Prompt Diffusion can comprehend the desired task and generate the corresponding output image on both seen (trained) and unseen (new) task types." | ||
|
||
For any usage questions, please refer to the [paper](https://arxiv.org/abs/2305.01115). | ||
|
||
Prepare models by converting them from the [checkpoint](https://huggingface.co/zhendongw/prompt-diffusion) | ||
|
||
To convert the controlnet, use cldm_v15.yaml from the [repository](https://github.com/Zhendong-Wang/Prompt-Diffusion/tree/main/models/): | ||
|
||
```bash | ||
python convert_original_promptdiffusion_to_diffusers.py --checkpoint_path path-to-network-step04999.ckpt --original_config_file path-to-cldm_v15.yaml --dump_path path-to-output-directory | ||
``` | ||
|
||
To learn about how to convert the fine-tuned stable diffusion model, see the [Load different Stable Diffusion formats guide](https://huggingface.co/docs/diffusers/main/en/using-diffusers/other-formats). | ||
|
||
|
||
```py | ||
import torch | ||
from diffusers import UniPCMultistepScheduler | ||
from diffusers.utils import load_image | ||
from promptdiffusioncontrolnet import PromptDiffusionControlNetModel | ||
from pipeline_prompt_diffusion import PromptDiffusionPipeline | ||
|
||
|
||
from PIL import ImageOps | ||
|
||
image_a = ImageOps.invert(load_image("https://github.com/Zhendong-Wang/Prompt-Diffusion/blob/main/images_to_try/house_line.png?raw=true")) | ||
|
||
image_b = load_image("https://github.com/Zhendong-Wang/Prompt-Diffusion/blob/main/images_to_try/house.png?raw=true") | ||
query = ImageOps.invert(load_image("https://github.com/Zhendong-Wang/Prompt-Diffusion/blob/main/images_to_try/new_01.png?raw=true")) | ||
|
||
# load prompt diffusion controlnet and prompt diffusion | ||
|
||
controlnet = PromptDiffusionControlNetModel.from_pretrained("path-to-promptdiffusion-controlnet", torch_dtype=torch.float16) | ||
model_id = "path-to-model" | ||
pipe = PromptDiffusionPipeline.from_pretrained(model_id, controlnet=controlnet, torch_dtype=torch.float16, variant="fp16") | ||
|
||
# speed up diffusion process with faster scheduler and memory optimization | ||
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) | ||
# remove following line if xformers is not installed | ||
pipe.enable_xformers_memory_efficient_attention() | ||
pipe.enable_model_cpu_offload() | ||
# generate image | ||
generator = torch.manual_seed(0) | ||
image = pipe("a tortoise", num_inference_steps=20, generator=generator, image_pair=[image_a,image_b], image=query).images[0] | ||
|
||
``` |
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.
I think it makes sense to first talk about how this checkpoint was obtained i.e., an example command of running the conversion.
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.
Could you provide the checkpoint path from the Hub directly? I.e., it could make sense to directly load it from the Hub? A few options:
Let me know what you think.
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.
Zhendong-Wang/Prompt-Diffusion#12 No official release date, so mine has to suffice.