ml-stable-diffusion icon indicating copy to clipboard operation
ml-stable-diffusion copied to clipboard

Bug/Expected? Why does the 2 schedulers have different Step counts when generating images in latest code?

Open H1p3ri0n opened this issue 2 years ago • 1 comments

dpmpp

swift run StableDiffusionSample "a photo of an astronaut riding a horse on mars" --resource-path Models/SD2Base-Split --output-path ./ --compute-units all --scheduler dpmpp Step 49 of 50 [mean: 1.93, median: 1.99, last 1.91] step/sec Saved a_photo_of_an_astronaut_riding_a_horse_on_mars.115519789.final.png

pndm

swift run StableDiffusionSample "a photo of an astronaut riding a horse on mars" --resource-path Models/SD2Base-Split --output-path ./ --compute-units all --scheduler pndm Step 50 of 51 [mean: 2.00, median: 2.01, last 1.97] step/sec Saved a_photo_of_an_astronaut_riding_a_horse_on_mars.143458175.final.png

The two schedulers implementation seems different to calculate timeSteps.

H1p3ri0n avatar Mar 06 '23 05:03 H1p3ri0n

I think this is not an issue at all, it's simply because you use different schedulers which do the inference steps in more or less steps. Those steps correlate to the step count parameter, but are not necessarily identical.

If you compare the equivalent schedulers used by the python script (PNDM and DPMSolverMultistep from diffusers/schedulers/), you'll see that DPMSolverMultistep is running 50 iterations and PNDM 51 iterations... same as for Swift.

According to my understanding this is basically an internal implementation detail of the schedulers.

The differences between the two available Swift schedulers are mainly that dpmpp reaches good quality after 35 steps and pndm needs 50. The Euler scheduler (currently not implemented in Swift) would achieve good results in even 20-30 steps.

pd95 avatar May 05 '23 22:05 pd95