LaurentMazare / diffusers-rs

An implementation of the diffusers api in Rust
Apache License 2.0
539 stars 55 forks source link

Implement Euler Ancestral Discrete scheduler #34

Closed mspronesti closed 1 year ago

mspronesti commented 1 year ago

Hi @LaurentMazare, this PR aims at integrating the Euler Ancestral Discrete Scheduler into this repository, solving the second task mentioned in #23 .

It includes all the features implemented in HF's Python version.

All the considerations made in my last PR, regarding the need to generalize the examples, still apply here.

sssemil commented 1 year ago

image

Tried this with sd1.5 and this prompt:

    "n_steps": 21,
    "seed": 1573789502,
    "prompt": "A rusty robot holding a fire torch.",
    "guidance_scale": 7.5

I think something is wrong here, or in my code.

mspronesti commented 1 year ago

Hi @sssemil, I tried with HF python diffusers, using your same config (expect the seed) and here are some images with different seeds. To me they seem aligned with the one you obtained with my code.

image

image

image

sssemil commented 1 year ago

Hm, but at the same time, this is what I get with python snippet you wrote in another thread: image

And this looks better.

mspronesti commented 1 year ago

Did you change the scheduler and the number of inference steps (some of those snippets have 1000)? I tried several times with that same snippet and the appropriate scheduler. Here are other examples I just produced

image

image

image

I leave the exact snippet hereby, to make sure we're using the same one

import torch
from diffusers import StableDiffusionPipeline, EulerAncestralDiscreteScheduler

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)

pipe.scheduler = EulerAncestralDiscreteScheduler()

pipe = pipe.to("cuda")
prompt = "A very rusty robot holding a fire torch."
image = pipe(prompt, num_inference_steps=21).images[0]  
image
sssemil commented 1 year ago

I think I ran it with 50 steps before, here's with 21: image

Welp, then it's similar results.

mspronesti commented 1 year ago

Happy to help :+1:

LaurentMazare commented 1 year ago

Merged, thanks for all the scheduler hard work!

mspronesti commented 1 year ago

Thanks for merging! (maybe forgot to push after git merge?)

LaurentMazare commented 1 year ago

Oh right sorry about that!