From b30be7d90f089a3bb032bccbf1019814c1531d80 Mon Sep 17 00:00:00 2001 From: sayakpaul Date: Tue, 13 Jan 2026 09:52:22 +0530 Subject: [PATCH] fix ip adapter type checking. --- src/diffusers/loaders/ip_adapter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/diffusers/loaders/ip_adapter.py b/src/diffusers/loaders/ip_adapter.py index b8f00fe6c5..13bb44e4a2 100644 --- a/src/diffusers/loaders/ip_adapter.py +++ b/src/diffusers/loaders/ip_adapter.py @@ -13,6 +13,7 @@ # limitations under the License. from pathlib import Path +from typing import List, Union import torch import torch.nn.functional as F @@ -822,18 +823,18 @@ class FluxIPAdapterMixin: ``` """ - scale_type = int | float + scale_type = Union[int, float] num_ip_adapters = self.transformer.encoder_hid_proj.num_ip_adapters num_layers = self.transformer.config.num_layers # Single value for all layers of all IP-Adapters if isinstance(scale, scale_type): scale = [scale for _ in range(num_ip_adapters)] - # list of per-layer scales for a single IP-Adapter - elif _is_valid_type(scale, list[scale_type]) and num_ip_adapters == 1: + # List of per-layer scales for a single IP-Adapter + elif _is_valid_type(scale, List[scale_type]) and num_ip_adapters == 1: scale = [scale] # Invalid scale type - elif not _is_valid_type(scale, list[scale_type | list[scale_type]]): + elif not _is_valid_type(scale, List[Union[scale_type, List[scale_type]]]): raise TypeError(f"Unexpected type {_get_detailed_type(scale)} for scale.") if len(scale) != num_ip_adapters: