ford442 commited on
Commit
c5c93cb
·
verified ·
1 Parent(s): 3535beb

Update ip_adapter/ip_adapter.py

Browse files
Files changed (1) hide show
  1. ip_adapter/ip_adapter.py +6 -5
ip_adapter/ip_adapter.py CHANGED
@@ -25,7 +25,7 @@ class ImageProjModel(torch.nn.Module):
25
  clip_extra_context_tokens = self.proj(embeds).reshape(-1, self.clip_extra_context_tokens, self.cross_attention_dim)
26
  clip_extra_context_tokens = self.norm(clip_extra_context_tokens)
27
  return clip_extra_context_tokens
28
-
29
  class IPAdapter:
30
 
31
  def __init__(self, sd_pipe, image_encoder_path, ip_ckpt, device, num_tokens=4):
@@ -180,7 +180,7 @@ class IPAdapter:
180
 
181
  return images
182
 
183
-
184
  class IPAdapterXL(IPAdapter):
185
  """SDXL"""
186
 
@@ -236,7 +236,8 @@ class IPAdapterXL(IPAdapter):
236
 
237
  image_prompt_embeds_list = []
238
  uncond_image_prompt_embeds_list = []
239
-
 
240
  image_prompt_embeds_1, uncond_image_prompt_embeds_1 = self.get_image_embeds(pil_image_1)
241
  image_prompt_embeds_list.append(image_prompt_embeds_1)
242
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_1)
@@ -254,13 +255,13 @@ class IPAdapterXL(IPAdapter):
254
  image_prompt_embeds_list.append(image_prompt_embeds_3)
255
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_3)
256
  if pil_image_4 != None:
257
- print('Using secondary image.')
258
  image_prompt_embeds_4, uncond_image_prompt_embeds_4 = self.get_image_embeds(pil_image_4)
259
  image_prompt_embeds_4 = image_prompt_embeds_4 * scale_4
260
  image_prompt_embeds_list.append(image_prompt_embeds_4)
261
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_4)
262
  if pil_image_5 != None:
263
- print('Using secondary image.')
264
  image_prompt_embeds_5, uncond_image_prompt_embeds_5 = self.get_image_embeds(pil_image_5)
265
  image_prompt_embeds_5 = image_prompt_embeds_5 * scale_5
266
  image_prompt_embeds_list.append(image_prompt_embeds_5)
 
25
  clip_extra_context_tokens = self.proj(embeds).reshape(-1, self.clip_extra_context_tokens, self.cross_attention_dim)
26
  clip_extra_context_tokens = self.norm(clip_extra_context_tokens)
27
  return clip_extra_context_tokens
28
+ '''
29
  class IPAdapter:
30
 
31
  def __init__(self, sd_pipe, image_encoder_path, ip_ckpt, device, num_tokens=4):
 
180
 
181
  return images
182
 
183
+ '''
184
  class IPAdapterXL(IPAdapter):
185
  """SDXL"""
186
 
 
236
 
237
  image_prompt_embeds_list = []
238
  uncond_image_prompt_embeds_list = []
239
+ print('Using primary image.')
240
+
241
  image_prompt_embeds_1, uncond_image_prompt_embeds_1 = self.get_image_embeds(pil_image_1)
242
  image_prompt_embeds_list.append(image_prompt_embeds_1)
243
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_1)
 
255
  image_prompt_embeds_list.append(image_prompt_embeds_3)
256
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_3)
257
  if pil_image_4 != None:
258
+ print('Using quaternary image.')
259
  image_prompt_embeds_4, uncond_image_prompt_embeds_4 = self.get_image_embeds(pil_image_4)
260
  image_prompt_embeds_4 = image_prompt_embeds_4 * scale_4
261
  image_prompt_embeds_list.append(image_prompt_embeds_4)
262
  uncond_image_prompt_embeds_list.append(uncond_image_prompt_embeds_4)
263
  if pil_image_5 != None:
264
+ print('Using quinary image.')
265
  image_prompt_embeds_5, uncond_image_prompt_embeds_5 = self.get_image_embeds(pil_image_5)
266
  image_prompt_embeds_5 = image_prompt_embeds_5 * scale_5
267
  image_prompt_embeds_list.append(image_prompt_embeds_5)