Skip to content
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

allow pndm scheduler to be used with ldm pipeline #165

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

patil-suraj
Copy link
Contributor

The Stable diffusion model uses PNDM as the main scheduler. Right now it's not possible to use PNDM scheduler in LDMText2ImagePipeline as the eta for DDIM is always passed to step method. The PNDMScheduler does not have this argument.

This PR adds **kwargs in PNDMScheduler.step and passes eta as kwarg in LDMText2ImagePipeline, so that the pipeline can be used with both schedulers. Since both LDM and stable diffusion model can be used with both these schedulers it's important to allow this interoperability.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 11, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@anton-l anton-l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@patil-suraj patil-suraj merged commit 3228eb1 into main Aug 11, 2022
@patil-suraj patil-suraj deleted the allow-pndm-in-ldm branch August 11, 2022 09:28
@@ -113,6 +113,7 @@ def step(
model_output: Union[torch.FloatTensor, np.ndarray],
timestep: int,
sample: Union[torch.FloatTensor, np.ndarray],
**kwargs,
Copy link
Contributor

@patrickvonplaten patrickvonplaten Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patil-suraj @anton-l - I'd prefer a bit to keep the schedulers as clean as possible and instead make the pipeline more hacky.

Could we maybe delete the unused kwargs here and instead make use of inspect.signature in the pipeline?
Analogs to https://github.com/huggingface/transformers/blob/05d3a43c59dadf815fe46df8fed8cc8e816c8588/src/transformers/generation_utils.py#L1171

Note that the schedulers should eventually work for all frameworks and it's IMO components where we strongly favor readability and intuitive design over hacky/easy-to-use.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I didn't think of using inspect.signature. I am also not in full favor of adding unused arguments, but didn't find a better solution so went with it as I wanted to get it rolling today.

Will remove this and adapt the pipeline.

PhaneeshB pushed a commit to nod-ai/diffusers that referenced this pull request Mar 1, 2023
rewrite some tflite code from SharkImporter to tflite_utils.py
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants