-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[0.28.0.dev0] In ControlNetModel forward function, added_cond_kwargs arg's default value should be {} rather than None #8380
Comments
Update diffusers-cli env info:
|
I don't think we need to default to |
Yes, you are right. Thank you for quick response! But this naturally lead to one question: when the user use SDXL model, why does the code raise the ValueError exception? The minimal replication code snippet is the following: from diffusers import AutoPipelineForInpainting, StableDiffusionControlNetInpaintPipeline,ControlNetModel """ build diffusion model pipeline """ img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png" image = load_image(img_url).resize((1024, 1024)) prompt = "a tiger sitting on a park bench" generated_image = pipe( The above code would encounter the ValueError as added_cond_kwargs is None by default. So, currently, diffusers just doesn't support diffusers/stable-diffusion-xl-1.0-inpainting-0.1 + xinsir/controlnet-canny-sdxl-1.0 pipeline ?Or this is just a bug of diffusers ? |
You are not using the right class. You need to use this: diffusers/src/diffusers/pipelines/controlnet/pipeline_controlnet_inpaint_sd_xl.py Line 154 in 4136044
|
Yes, you are right, after switching to StableDiffusionXLControlNetInpaintPipeline, the code just runs fine. Thanks again for your kind and quick response! I would close this issue now. |
Describe the bug
Version: [0.28.0.dev0]
Bug description: In ControlNetModel forward function, added_cond_kwargs arg's default value should be {} rather than None
Reason: in the source code(controlnet.py):
elif self.config.addition_embed_type == "text_time":
if "text_embeds" not in added_cond_kwargs:
raise ValueError(
f"{self.class} has the config param
addition_embed_type
set to 'text_time' which requires the keyword argumenttext_embeds
to be passed inadded_cond_kwargs
")
If the default value is None, this code would raise a ValueError
Pull request: I intend to submit a pull request for this issue.
Reproduction
from diffusers import AutoPipelineForInpainting, StableDiffusionControlNetInpaintPipeline,ControlNetModel
from diffusers.utils import load_image
import torch
controlnet_canny = ControlNetModel.from_pretrained(
"xinsir/controlnet-canny-sdxl-1.0",
torch_dtype=torch.float16
)
print(f"=> controlnet_canny is ready")
pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained(
"diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
controlnet=controlnet_canny,
torch_dtype=torch.float16, variant="fp16",
).to("cuda")
img_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
image = load_image(img_url).resize((1024, 1024))
mask_image = load_image(mask_url).resize((1024, 1024))
canny_image = get_canny_edge(image)
prompt = "a tiger sitting on a park bench"
generator = torch.Generator(device="cuda").manual_seed(0)
generated_image = pipe(
prompt=prompt,
image=image,
mask_image=mask_image,
control_image=canny_image,
guidance_scale=8.0,
num_inference_steps=20, # steps between 15 and 30 work well for us
strength=0.99, # make sure to use
strength
below 1.0generator=generator,
).images[0]
Logs
No response
System Info
Who can help?
@sayakpaul @yiyixuxu
The text was updated successfully, but these errors were encountered: