Skip to content

fix bug in StableDiffusionXLControlNetPipeline when use guess_mode - #4799

Merged
yiyixuxu merged 7 commits into
mainfrom
sdxl-controlnet-guess
Aug 28, 2023
Merged

fix bug in StableDiffusionXLControlNetPipeline when use guess_mode#4799
yiyixuxu merged 7 commits into
mainfrom
sdxl-controlnet-guess

Conversation

@yiyixuxu

Copy link
Copy Markdown
Collaborator

This PR fix a bug in sdxl controlnet when guess_mode=True

It fix#4709 and I think it does the same thing as #4155 but we don't need to drastically change the code structure

fromdiffusersimportStableDiffusionXLControlNetPipeline, ControlNetModel, AutoencoderKLfromdiffusers.utilsimportload_imageimportnumpyasnpimporttorchimportcv2fromPILimportImageprompt="aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"negative_prompt="low quality, bad quality, sketches"image=load_image(
"https://hf.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png"
)
controlnet_conditioning_scale=0.5# recommended for good generalizationcontrolnet=ControlNetModel.from_pretrained(
"diffusers/controlnet-canny-sdxl-1.0", torch_dtype=torch.float16
)
vae=AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
pipe=StableDiffusionXLControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, vae=vae, torch_dtype=torch.float16
)
pipe.enable_model_cpu_offload()
image=np.array(image)
image=cv2.Canny(image, 100, 200)
image=image[:, :, None]
image=np.concatenate([image, image, image], axis=2)
canny_image=Image.fromarray(image)
image=pipe(
prompt, controlnet_conditioning_scale=controlnet_conditioning_scale, image=canny_image, guess_mode=True,
).images[0]
image.save("guess_mode_out.png")

guess_out

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Aug 27, 2023

Copy link
Copy Markdown

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten

Copy link
Copy Markdown
Contributor

Cool! One quick fast/dummy test for this one?

@patrickvonplaten

Copy link
Copy Markdown
Contributor

Very nice! Looks good to me - let's maybe add this also to our SDXL controlnet docs in a follow-up PR (cc @stevhliu)

Think the test is also currently failing on the CI - can we make it more deterministic?

@patrickvonplatenpatrickvonplaten left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! @sayakpaul maybe for a final review?

@sayakpaulsayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic definitely reads simplistic now. Thank you!

@yiyixuxu
yiyixuxu merged commit 934d439 into mainAug 28, 2023
@kashif
kashif deleted the sdxl-controlnet-guess branch September 11, 2023 19:06
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…uggingface#4799)
* fix
---------
Co-authored-by: yiyixuxu <yixu310@gmail,com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…uggingface#4799)
* fix
---------
Co-authored-by: yiyixuxu <yixu310@gmail,com>
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StableDiffusionXLControlNetPipeline NOT Support Guess Mode

4 participants

@yiyixuxu@HuggingFaceDocBuilderDev@patrickvonplaten@sayakpaul