-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Stable diffusion pipeline #168
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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.
Looks good to me!
Looks good to me! One minor question: since this is only for |
Good remark - think this makes sense! It'll make the code cleaner and we could always add it later to the party |
Good point @pcuenca ! I agree with this, but since the original codebase allows to play with both DDIM and PNDM, think it would important to have the |
@patrickvonplaten @anton-l
|
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
Outdated
Show resolved
Hide resolved
# expand the latents if we are doing classifier free guidance | ||
if do_classifier_free_guidance: | ||
latents = torch.cat((latents, latents), dim=0) |
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.
since text_embeddings
are already expanded, we only need to expand latents
here.
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.
that gave a problem with naming but should be fixed now
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py
Outdated
Show resolved
Hide resolved
|
||
for t in tqdm(self.scheduler.timesteps): | ||
# expand the latents if we are doing classifier free guidance | ||
latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents |
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.
@patil-suraj there was a bug with the naming here -> corrected it
if torch_device is None: | ||
torch_device = "cuda" if torch.cuda.is_available() else "cpu" | ||
|
||
if isinstance(prompt, str): |
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.
@patil-suraj -> made sure a string can be passed as input
self.text_encoder.to(torch_device) | ||
|
||
# get prompt text embeddings | ||
text_input = self.tokenizer(prompt, padding=True, truncation=True, return_tensors="pt") |
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.
@patil-suraj removed the weird 77 max length here
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.
Merging now! Tested it and it works fine
* add stable diffusion pipeline * get rid of multiple if/else * batch_size is unused * add type hints * Update src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py * fix some bugs Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
This PR adds
StableDiffusionPipeline