Skip to content

[ip-adapter] make sure length of scale is same as number of ip-adapters when using set_ip_adapter_scale - #6884

Merged
yiyixuxu merged 1 commit into
mainfrom
fix-ip-adapter-scale
Feb 7, 2024
Merged

[ip-adapter] make sure length of scale is same as number of ip-adapters when using set_ip_adapter_scale#6884
yiyixuxu merged 1 commit into
mainfrom
fix-ip-adapter-scale

Conversation

@yiyixuxu

Copy link
Copy Markdown
Collaborator
importtorchfromdiffusersimportAutoPipelineForText2Imagepipeline=AutoPipelineForText2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16
)
pipeline.load_ip_adapter(
"h94/IP-Adapter", subfolder="sdxl_models", weight_name=["ip-adapter-plus_sdxl_vit-h.safetensors", "ip-adapter-plus-face_sdxl_vit-h.safetensors"]
)
print(f" testing scale = 0.7")
try:
pipeline.set_ip_adapter_scale(0.7)
exceptExceptionase:
print(f"Error: {e}")
print(f" testing scale = [0.7]")
try:
pipeline.set_ip_adapter_scale([0.7])
exceptExceptionase:
print(f"Error: {e}")
print(f" testing scale = [0.7, 0.6]")
try:
pipeline.set_ip_adapter_scale([0.7, 0.6])
exceptExceptionase:
print(f"Error: {e}"
)
print(f" testing scale = [0.7, 0.5, 0.6]")
try:
pipeline.set_ip_adapter_scale([0.7, 0.5, 0.6])
exceptExceptionase:
print(f"Error: {e}")

outputs are expected

 testing scale = 0.7
testing scale = [0.7]
Error: `scale` should be a list of same length as the number if ip-adapters Expected 2 but got 1.
testing scale = [0.7, 0.6]
testing scale = [0.7, 0.5, 0.6]
Error: `scale` should be a list of same length as the number if ip-adapters Expected 2 but got 3.

@yiyixuxuyiyixuxu mentioned this pull request Feb 7, 2024
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@yiyixuxu

Copy link
Copy Markdown
CollaboratorAuthor

@asomoza feel free to give this a 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.

So good!

I believe the testing will be added in #6829?

@asomozaasomoza 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.

thank you, this resolves the issue.

@yiyixuxu
yiyixuxu merged commit 97d004b into mainFeb 7, 2024
@yiyixuxu
yiyixuxu deleted the fix-ip-adapter-scale branch February 7, 2024 20:13
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…ters when using `set_ip_adapter_scale` (huggingface#6884)
add
Co-authored-by: yiyixuxu <yixu310@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.

4 participants

@yiyixuxu@HuggingFaceDocBuilderDev@asomoza@sayakpaul