set_ip_adapter_scale(float) raises "Cannot assign 1 scale_configs to 2 IP-Adapter" when several IP-Adapters are loaded

オープン 初心者向け
#15,210 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

既存のブロードキャスト動作を確認するため、IPAdapterMixin と ModularIPAdapterMixin の set_ip_adapter_scale を読み、FluxIPAdapterMixin.set_ip_adapter_scale も確認してください。issue では長さチェックの順序が指摘され、小さなパイプラインでの再現例が示されています。テスト用アダプターを2つ読み込んだ状態でfloatを1つ渡すケースのテストを追加し、スケールが両方に適用されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

With more than one IP-Adapter loaded, set_ip_adapter_scale(0.6) raises ValueError: Cannot assign 1 scale_configs to 2 IP-Adapter. instead of applying the scale to every adapter. A list with one value per adapter works.

set_ip_adapter_scale already has a branch meant to repeat a single config for every adapter (elif len(scale_configs) == 1: scale_configs = scale_configs * len(attn_processor.scale)), but it comes after the length check, so it never runs. A single float was broadcast before #7668, and the Flux version (FluxIPAdapterMixin.set_ip_adapter_scale) still broadcasts it. The same code is in ModularIPAdapterMixin.set_ip_adapter_scale.

I'd like to send a PR that checks the single-config case first (a two-line swap in both mixins) plus a test.

Reproduction

Shown with the tiny test pipeline and two test IP-Adapters so it runs in seconds; it goes through the same set_ip_adapter_scale code as load_ip_adapter("h94/IP-Adapter", ...) with two weight_names on SD1.5.

# Run from the root of a diffusers checkout (uses the test helpers for a tiny pipeline and IP-Adapter weights).
from tests.models.unets.test_models_unet_2d_condition import create_ip_adapter_state_dict
from tests.pipelines.stable_diffusion.test_stable_diffusion import StableDiffusionPipelineTesterConfig

cfg = StableDiffusionPipelineTesterConfig()
pipe = cfg.pipeline_class(**cfg.get_dummy_components())
state_dicts = [create_ip_adapter_state_dict(pipe.unet) for _ in range(2)]
pipe.load_ip_adapter(state_dicts, subfolder=["", ""], weight_name=["", ""], image_encoder_folder=None)

pipe.set_ip_adapter_scale([0.6, 0.6])  # works
pipe.set_ip_adapter_scale(0.6)  # ValueError
Context

I found this while testing set_ip_adapter_scale with two IP-Adapters loaded.

Logs
ValueError: Cannot assign 1 scale_configs to 2 IP-Adapter.
System Info
- 🤗 Diffusers version: 0.42.0.dev0 (main @ 84532a058)
- Platform: macOS-26.6.2-arm64-arm-64bit
- Running on Google Colab?: No
- Python version: 3.12.11
- PyTorch version (GPU?): 2.15.0 (False)
- Huggingface_hub version: 2.4.0
- Transformers version: 5.22.2
- Accelerate version: 1.15.0
- PEFT version: 0.21.2
- Safetensors version: 0.8.0
- xFormers version: not installed
- Accelerator: Apple M5 Pro
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
Who can help?

@asomoza @yiyixuxu

主要言語
Python
スター
34.9k
フォーク
7.5k
平均マージ
2日 16時間
マージ済み PR(30日)
57

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

huggingface/diffusers のほかの issue

huggingface/diffusers の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。