fix the plus models with image batches
This commit is contained in:
+2
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user