Experimental per control type scale for ControlNet Union#10723
Merged
hlky merged 7 commits intohuggingface:mainfrom Feb 27, 2025
Merged
Experimental per control type scale for ControlNet Union#10723hlky merged 7 commits intohuggingface:mainfrom
hlky merged 7 commits intohuggingface:mainfrom
Conversation
|
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. |
6 tasks
yiyixuxu
approved these changes
Feb 6, 2025
|
Is this one possible to use pro-max version as well? Thanks |
6 tasks
Contributor
Author
|
@john09282922 Yes. |
Contributor
Author
import torch
from diffusers import StableDiffusionXLControlNetUnionPipeline
from diffusers.models import ControlNetUnionModel, AutoencoderKL
from diffusers.utils import load_image
room_seg_img = load_image(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/room_seg.png"
)
pose_img = load_image(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/pose.png"
)
controlnet = ControlNetUnionModel.from_pretrained(
"brad-twinkl/controlnet-union-sdxl-1.0-promax", 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="an astronaut in space",
width=1024,
height=1024,
negative_prompt="lowres, low quality, worst quality",
control_image=[pose_img, room_seg_img],
control_mode=[0, 5],
#controlnet_conditioning_scale=[0.0, 1.0],
num_inference_steps=50,
generator=torch.Generator().manual_seed(42),
).images[0]
image.save("result.jpg")Also unifies the interface for MultiControlNet cc @vladmandic simply splits to list of list internally cc @guiyrt
Uses standard scaling with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.






What does this PR do?
This adds experimental support for per control type scale to ControlNet Union.
Code
Control images
Canny:control_image=[canny]Canny Seg:control_image=[seg, canny]Canny No Seg:control_image=[seg, canny]withcontrolnet_conditioning_scale=[0.0, 1.0]Fixes #10656
Note: we will also add
MultiControlNetsupport 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