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

Switch to SD v1.5 #12

Closed
143f86b6-91b7-47e4-808b-18779e22f2dd opened this issue Nov 14, 2022 · 4 comments
Closed

Switch to SD v1.5 #12

143f86b6-91b7-47e4-808b-18779e22f2dd opened this issue Nov 14, 2022 · 4 comments

Comments

@143f86b6-91b7-47e4-808b-18779e22f2dd

Is it possible to use this in v1.5 instead of v1.4?

@0xdevalias
Copy link

0xdevalias commented Nov 15, 2022

This is documented in the README already:


You can see that pww_load_tools takes a hf_model_path and/or local_model_path here:

def pww_load_tools(
device: str = "cuda:0",
scheduler_type=LMSDiscreteScheduler,
local_model_path: Optional[str] = None,
hf_model_path: Optional[str] = None,

pww_load_tools is called by paint_with_words, which can also be passed hf_model_path and/or local_model_path, with hf_model_path defaulting to "CompVis/stable-diffusion-v1-4"

def paint_with_words(
color_context: Dict[Tuple[int, int, int], str] = {},
color_map_image: Optional[Image.Image] = None,
input_prompt: str = "",
num_inference_steps: int = 30,
guidance_scale: float = 7.5,
seed: int = 0,
scheduler_type=LMSDiscreteScheduler,
device: str = "cuda:0",
weight_function: Callable = lambda w, sigma, qk: 0.1
* w
* math.log(sigma + 1)
* qk.max(),
local_model_path: Optional[str] = None,
hf_model_path: Optional[str] = "CompVis/stable-diffusion-v1-4",
preloaded_utils: Optional[Tuple] = None,
unconditional_input_prompt: str = "",
):
vae, unet, text_encoder, tokenizer, scheduler = (
pww_load_tools(
device,
scheduler_type,
local_model_path=local_model_path,
hf_model_path=hf_model_path,
)

So it looks like it may be even easier than the README suggests, and you should just be able to pass "runwayml/stable-diffusion-v1-5" directly into the hf_model_path parameter of paint_with_words as it's called in the 'Basic Usage' section:

Something like this would presumably work:

img = paint_with_words(
    color_context=color_context,
    color_map_image=color_map_image,
    input_prompt=input_prompt,
    num_inference_steps=30,
    guidance_scale=7.5,
    device="cuda:0",
+   hf_model_path="runwayml/stable-diffusion-v1-5"
)

@0xdevalias
Copy link

I made a simple colab example just now, you can try it out here: paint-with-words colab

Originally posted by @shreydan in #4 (comment)

You can confirm the above hf_model_path change on the colab mentioned here by editing the cell that has the img = paint_with_words( (first cell after the 'Run Model' heading)

We can also explicitly set the seed parameter here as well, to make comparisons between the 2 models easier.

Original version using SD v1.4

image
image

New version using SD v1.5

image
image

@hiss-remi
Copy link

You can see that pww_load_tools takes a hf_model_path and/or local_model_path here:

One advantage of this method that you can also change the scheduler, which might be desirable for performance or quality issues. (I found recently that the model I'm using often has blatant graphical issues even with a large step count on LMS, but EulerAncestralDiscreteScheduler or EulerDiscreteScheduler do much better. Just don't forget to import your scheduler of choice from diffusers. (Something the example currently doesn't show.)

@cloneofsimo
Copy link
Owner

Nice note @hiss-remi , ill add this feature as well.

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

No branches or pull requests

4 participants