From 7171f5b11722a860f1237afa9723c30ee010c984 Mon Sep 17 00:00:00 2001 From: matt3o Date: Wed, 27 Sep 2023 12:24:45 +0200 Subject: [PATCH] fix the plus models with image batches --- IPAdapterPlus.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/IPAdapterPlus.py b/IPAdapterPlus.py index 9c94a88..6ccfa77 100644 --- a/IPAdapterPlus.py +++ b/IPAdapterPlus.py @@ -94,8 +94,7 @@ def image_add_noise(image, noise): image = image + ((0.25*(1-noise)+0.05) * torch.randn_like(image) ) # add random noise return image -def zeroed_hidden_states(clip_vision): - image = torch.zeros( [1, 224, 224, 3] ) +def zeroed_hidden_states(clip_vision, image): img = torch.clip((255. * image), 0, 255).round().int() img = list(map(lambda a: a, img)) inputs = clip_vision.processor(images=img, return_tensors="pt") @@ -314,7 +313,7 @@ class IPAdapterApply: if noise > 0: clip_embed_zeroed = clip_vision.encode_image(neg_image).penultimate_hidden_states else: - clip_embed_zeroed = zeroed_hidden_states(clip_vision) + clip_embed_zeroed = zeroed_hidden_states(clip_vision, image) else: clip_extra_context_tokens = 4 clip_embed = clip_embed.image_embeds