Spaces:
Runtime error
Runtime error
Update ip_adapter/ip_adapter.py
Browse files- ip_adapter/ip_adapter.py +6 -20
ip_adapter/ip_adapter.py
CHANGED
|
@@ -125,10 +125,6 @@ class IPAdapter:
|
|
| 125 |
self,
|
| 126 |
pil_image,
|
| 127 |
prompt=None,
|
| 128 |
-
prompt2=None,
|
| 129 |
-
prompt3=None,
|
| 130 |
-
prompt4=None,
|
| 131 |
-
prompt5=None,
|
| 132 |
negative_prompt=None,
|
| 133 |
scale=1.0,
|
| 134 |
num_samples=4,
|
|
@@ -173,22 +169,6 @@ class IPAdapter:
|
|
| 173 |
prompt, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 174 |
negative_prompt_embeds_, prompt_embeds_ = prompt_embeds.chunk(2)
|
| 175 |
prompt_embeds_list.append(prompt_embeds)
|
| 176 |
-
if prompt2 is not None:
|
| 177 |
-
prompt_embeds = self.pipe._encode_prompt(
|
| 178 |
-
prompt2, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 179 |
-
prompt_embeds_list.append(prompt_embeds)
|
| 180 |
-
if prompt3 is not None:
|
| 181 |
-
prompt_embeds = self.pipe._encode_prompt(
|
| 182 |
-
prompt3, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 183 |
-
prompt_embeds_list.append(prompt_embeds)
|
| 184 |
-
if prompt4 is not None:
|
| 185 |
-
prompt_embeds = self.pipe._encode_prompt(
|
| 186 |
-
prompt4, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 187 |
-
prompt_embeds_list.append(prompt_embeds)
|
| 188 |
-
if prompt5 is not None:
|
| 189 |
-
prompt_embeds = self.pipe._encode_prompt(
|
| 190 |
-
prompt5, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 191 |
-
prompt_embeds_list.append(prompt_embeds)
|
| 192 |
|
| 193 |
prompt_embeds = torch.cat([prompt_embeds_, image_prompt_embeds], dim=1)
|
| 194 |
negative_prompt_embeds = torch.cat([negative_prompt_embeds_, uncond_image_prompt_embeds], dim=1)
|
|
@@ -226,6 +206,7 @@ class IPAdapterXL(IPAdapter):
|
|
| 226 |
pil_image_4=None,
|
| 227 |
pil_image_5=None,
|
| 228 |
prompt=None,
|
|
|
|
| 229 |
prompt2=None,
|
| 230 |
prompt3=None,
|
| 231 |
prompt4=None,
|
|
@@ -315,6 +296,11 @@ class IPAdapterXL(IPAdapter):
|
|
| 315 |
prompt, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 316 |
prompt_embeds_list.append(prompt_embeds)
|
| 317 |
pooled_prompt_embeds_list.append(pooled_prompt_embeds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
if prompt2 is not None:
|
| 319 |
prompt_embeds, negative_prompt_embeds_, pooled_prompt_embeds, negative_pooled_prompt_embeds_ = self.pipe.encode_prompt(
|
| 320 |
prompt2, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
|
|
|
| 125 |
self,
|
| 126 |
pil_image,
|
| 127 |
prompt=None,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
negative_prompt=None,
|
| 129 |
scale=1.0,
|
| 130 |
num_samples=4,
|
|
|
|
| 169 |
prompt, device=self.device, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 170 |
negative_prompt_embeds_, prompt_embeds_ = prompt_embeds.chunk(2)
|
| 171 |
prompt_embeds_list.append(prompt_embeds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
prompt_embeds = torch.cat([prompt_embeds_, image_prompt_embeds], dim=1)
|
| 174 |
negative_prompt_embeds = torch.cat([negative_prompt_embeds_, uncond_image_prompt_embeds], dim=1)
|
|
|
|
| 206 |
pil_image_4=None,
|
| 207 |
pil_image_5=None,
|
| 208 |
prompt=None,
|
| 209 |
+
prompt1=None,
|
| 210 |
prompt2=None,
|
| 211 |
prompt3=None,
|
| 212 |
prompt4=None,
|
|
|
|
| 296 |
prompt, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 297 |
prompt_embeds_list.append(prompt_embeds)
|
| 298 |
pooled_prompt_embeds_list.append(pooled_prompt_embeds)
|
| 299 |
+
if prompt1 is not None:
|
| 300 |
+
prompt_embeds, negative_prompt_embeds_, pooled_prompt_embeds, negative_pooled_prompt_embeds_ = self.pipe.encode_prompt(
|
| 301 |
+
prompt1, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|
| 302 |
+
prompt_embeds_list.append(prompt_embeds)
|
| 303 |
+
pooled_prompt_embeds_list.append(pooled_prompt_embeds)
|
| 304 |
if prompt2 is not None:
|
| 305 |
prompt_embeds, negative_prompt_embeds_, pooled_prompt_embeds, negative_pooled_prompt_embeds_ = self.pipe.encode_prompt(
|
| 306 |
prompt2, num_images_per_prompt=num_samples, do_classifier_free_guidance=True, negative_prompt=negative_prompt)
|