diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Missing easy way to set various renderers/samplers

Open paciox opened this issue 3 years ago • 3 comments

Describe the bug

(https://www.reddit.com/r/StableDiffusion/comments/wwm2at/sampler_vs_steps_comparison_low_to_mid_step_counts/?utm_medium=android_app&utm_source=share)

Check here, now

Now I launch it like this:
import sys
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline

model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"


pipe = StableDiffusionPipeline.from_pretrained(model_id, use_auth_token=True)
pipe = pipe.to(device)

image1 = pipe("SOME PROPMT", num_inference_steps=50, width=512, height=512)["sample"][0] 
  image1.save(f"aa.png")

NOw what if I want to set the others?

Reproduction

No response

Logs

No response

System Info

Windows 10, SD with 1.4 weights

paciox avatar Aug 31 '22 02:08 paciox

Hi @paciox! The recommended way to set a custom/alternative sampler for a pipeline is the following:

Load the scheduler's hyperparameters from another scheduler's config. Here we're loading the default scheduler's (PNDM's) params like beta_start, beta_end into LMS:

from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler

model_id = "CompVis/stable-diffusion-v1-4"
scheduler = LMSDiscreteScheduler(model_id, subfolder="scheduler", use_auth_token=True)
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True)
pipe = pipe.to("cuda")

anton-l avatar Aug 31 '22 16:08 anton-l

This is also related to: https://github.com/huggingface/diffusers/issues/336

patrickvonplaten avatar Sep 13 '22 15:09 patrickvonplaten

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Oct 08 '22 15:10 github-actions[bot]