Spaces:
Running
on
Zero
Running
on
Zero
1inkusFace
commited on
Update pipeline_stable_diffusion_3_ipa.py
Browse files
pipeline_stable_diffusion_3_ipa.py
CHANGED
@@ -922,8 +922,9 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
|
|
922 |
|
923 |
@torch.inference_mode()
|
924 |
def encode_clip_image_emb(self, clip_image, device, dtype):
|
925 |
-
|
926 |
-
|
|
|
927 |
clip_image_tensor = self.clip_image_processor(images=clip_image, return_tensors="pt").pixel_values
|
928 |
clip_image_tensor = clip_image_tensor.to(device, dtype=dtype)
|
929 |
clip_image_embeds = self.image_encoder(clip_image_tensor, output_hidden_states=True).hidden_states[-2]
|
@@ -1177,7 +1178,7 @@ class StableDiffusion3Pipeline(DiffusionPipeline, SD3LoraLoaderMixin, FromSingle
|
|
1177 |
|
1178 |
# Create a linear layer
|
1179 |
embedding_dim = concatenated_embeds.shape[-1] # Get the embedding dimension
|
1180 |
-
linear_layer = nn.Linear(
|
1181 |
# Move `concatenated_embeds` to the GPU if it's on the CPU
|
1182 |
'''
|
1183 |
if concatenated_embeds.device.type == 'cpu':
|
|
|
922 |
|
923 |
@torch.inference_mode()
|
924 |
def encode_clip_image_emb(self, clip_image, device, dtype):
|
925 |
+
if isinstance(clip_image, Image.Image):
|
926 |
+
clip_image = [clip_image]
|
927 |
+
# clip
|
928 |
clip_image_tensor = self.clip_image_processor(images=clip_image, return_tensors="pt").pixel_values
|
929 |
clip_image_tensor = clip_image_tensor.to(device, dtype=dtype)
|
930 |
clip_image_embeds = self.image_encoder(clip_image_tensor, output_hidden_states=True).hidden_states[-2]
|
|
|
1178 |
|
1179 |
# Create a linear layer
|
1180 |
embedding_dim = concatenated_embeds.shape[-1] # Get the embedding dimension
|
1181 |
+
linear_layer = nn.Linear(len(image_prompt_embeds_list) * embedding_dim, embedding_dim, dtype=torch.bfloat16).to('cuda')
|
1182 |
# Move `concatenated_embeds` to the GPU if it's on the CPU
|
1183 |
'''
|
1184 |
if concatenated_embeds.device.type == 'cpu':
|