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

Experimental per control type scale for ControlNet Union #10723

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hlky
Copy link
Collaborator

@hlky hlky commented Feb 5, 2025

What does this PR do?

This adds experimental support for per control type scale to ControlNet Union.

Code

from diffusers import (
    StableDiffusionXLControlNetUnionPipeline,
    ControlNetUnionModel,
    AutoencoderKL,
)
from diffusers.utils import load_image
import torch

prompt = "A bird"
seg = load_image("house_seg.png")
canny = load_image("bird_canny.png")
controlnet = ControlNetUnionModel.from_pretrained(
    "xinsir/controlnet-union-sdxl-1.0", torch_dtype=torch.float16
)
vae = AutoencoderKL.from_pretrained(
    "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
)
pipe = StableDiffusionXLControlNetUnionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    controlnet=controlnet,
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
)
pipe.enable_model_cpu_offload()
image = pipe(
    prompt,
    control_image=[seg, canny],
    control_mode=[5, 3],
    height=1024,
    width=1024,
    controlnet_conditioning_scale=[0.0, 1.0],
    generator=torch.Generator().manual_seed(0),
).images[0]

Control images

house_seg

bird_canny

Canny Canny Seg Canny No Seg
canny canny_seg canny_no_seg

Canny: control_image=[canny]
Canny Seg: control_image=[seg, canny]
Canny No Seg: control_image=[seg, canny] with controlnet_conditioning_scale=[0.0, 1.0]

Fixes #10656

Note: we will also add MultiControlNet support for ControlNet Union in another PR.

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu @asomoza @vladmandic

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hlky hlky mentioned this pull request Feb 5, 2025
6 tasks
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

Successfully merging this pull request may close these issues.

ControlNet union pipeline fails on multi-model
3 participants