-
Notifications
You must be signed in to change notification settings - Fork 6.1k
unCLIP variant #2297
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
williamberman
merged 16 commits into
huggingface:main
from
williamberman:pipeline_variant
Feb 14, 2023
Merged
unCLIP variant #2297
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
136c9f3
pipeline_variant
williamberman f203e1a
Add docs for when clip_stats_path is specified
williamberman b25971d
Update src/diffusers/pipelines/stable_diffusion/pipeline_stable_uncli…
williamberman 665e818
Update src/diffusers/pipelines/stable_diffusion/pipeline_stable_uncli…
williamberman ef80c29
Update src/diffusers/pipelines/stable_diffusion/pipeline_stable_uncli…
williamberman 338f299
Update src/diffusers/pipelines/stable_diffusion/pipeline_stable_uncli…
williamberman a1df31a
prepare_latents # Copied from re: @patrickvonplaten
williamberman ee5f35e
NoiseAugmentor->ImageNormalizer
williamberman f8b6f43
Merge branch 'main' into pipeline_variant
williamberman 31a03d4
Merge branch 'main' into pipeline_variant
williamberman e3458b0
stable_unclip_prior default to None re: @patrickvonplaten
williamberman 4d62cf0
prepare_prior_extra_step_kwargs
williamberman f35b2e8
prior denoising scale model input
williamberman c872cbc
{DDIM,DDPM}Scheduler -> KarrasDiffusionSchedulers re: @patrickvonplaten
williamberman 19a2bbf
docs
williamberman b91ca13
Update docs/source/en/api/pipelines/stable_unclip.mdx
williamberman 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
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,97 @@ | ||
<!--Copyright 2022 The HuggingFace Team. 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. | ||
--> | ||
|
||
# Stable unCLIP | ||
|
||
Stable unCLIP checkpoints are finetuned from [stable diffusion 2.1](./stable_diffusion_2) checkpoints to condition on CLIP image embeddings. | ||
Stable unCLIP also still conditions on text embeddings. Given the two separate conditionings, stable unCLIP can be used | ||
for text guided image variation. When combined with an unCLIP prior, it can also be used for full text to image generation. | ||
|
||
## Tips | ||
|
||
Stable unCLIP takes a `noise_level` as input during inference. `noise_level` determines how much noise is added | ||
to the image embeddings. A higher `noise_level` increases variation in the final un-noised images. By default, | ||
we do not add any additional noise to the image embeddings i.e. `noise_level = 0`. | ||
|
||
### Available checkpoints: | ||
|
||
TODO | ||
|
||
### Text-to-Image Generation | ||
|
||
```python | ||
import torch | ||
from diffusers import StableUnCLIPPipeline | ||
|
||
pipe = StableUnCLIPPipeline.from_pretrained( | ||
"fusing/stable-unclip-2-1-l", torch_dtype=torch.float16 | ||
) # TODO update model path | ||
pipe = pipe.to("cuda") | ||
|
||
prompt = "a photo of an astronaut riding a horse on mars" | ||
images = pipe(prompt).images | ||
images[0].save("astronaut_horse.png") | ||
``` | ||
|
||
|
||
### Text guided Image-to-Image Variation | ||
|
||
```python | ||
import requests | ||
import torch | ||
from PIL import Image | ||
from io import BytesIO | ||
|
||
from diffusers import StableUnCLIPImg2ImgPipeline | ||
|
||
pipe = StableUnCLIPImg2ImgPipeline.from_pretrained( | ||
"fusing/stable-unclip-2-1-l-img2img", torch_dtype=torch.float16 | ||
) # TODO update model path | ||
pipe = pipe.to("cuda") | ||
|
||
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg" | ||
|
||
response = requests.get(url) | ||
init_image = Image.open(BytesIO(response.content)).convert("RGB") | ||
init_image = init_image.resize((768, 512)) | ||
|
||
prompt = "A fantasy landscape, trending on artstation" | ||
|
||
images = pipe(prompt, init_image).images | ||
images[0].save("fantasy_landscape.png") | ||
``` | ||
|
||
### StableUnCLIPPipeline | ||
|
||
[[autodoc]] StableUnCLIPPipeline | ||
- all | ||
- __call__ | ||
- enable_attention_slicing | ||
- disable_attention_slicing | ||
- enable_vae_slicing | ||
- disable_vae_slicing | ||
- enable_xformers_memory_efficient_attention | ||
- disable_xformers_memory_efficient_attention | ||
|
||
|
||
### StableUnCLIPImg2ImgPipeline | ||
|
||
[[autodoc]] StableUnCLIPImg2ImgPipeline | ||
- all | ||
- __call__ | ||
- enable_attention_slicing | ||
- disable_attention_slicing | ||
- enable_vae_slicing | ||
- disable_vae_slicing | ||
- enable_xformers_memory_efficient_attention | ||
- disable_xformers_memory_efficient_attention | ||
|
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
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.
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.
Thanks!