From b7be2be24d90b0fb079c6e5f3206a8f3bc6f2f5c Mon Sep 17 00:00:00 2001 From: Stephen <> Date: Wed, 19 Jun 2024 21:47:50 +0800 Subject: [PATCH] made weight inversions relative to their own input instead of 1 minus --- IPAdapterPlus.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/IPAdapterPlus.py b/IPAdapterPlus.py index e54996e..ecf5349 100644 --- a/IPAdapterPlus.py +++ b/IPAdapterPlus.py @@ -1532,7 +1532,12 @@ class IPAdapterWeights: image_1 = image_1[1:] image_2 = image[1::2].repeat_interleave(2, 0) - mew_weights = weights + [1.0 - w for w in weights] + # Calculate the min and max of the weights + min_weight = min(weights) + max_weight = max(weights) + # Invert the weights relative to their own range + mew_weights = [max_weight - (w - min_weight) for w in weights] + mew_weights = mew_weights * (image_1.shape[0] // 2) if image.shape[0] % 2: image_1 = image_1[:-1] @@ -1559,7 +1564,10 @@ class IPAdapterWeights: if image_2 is not None: image_2 = torch.cat([image_2, image[-1:].repeat(add_ending_frames, 1, 1, 1)], dim=0) - weights_invert = [1.0 - w for w in weights] + # inversion relative to weights' own range + min_weight = min(weights) + max_weight = max(weights) + weights_invert = [max_weight - (w - min_weight) for w in weights] frame_count = len(weights)