"git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "44bc36d06301bbc23ea3cd4af935e24cfb945f33"
Unverified Commit 42cae93b authored by Dhruv Nair's avatar Dhruv Nair Committed by GitHub
Browse files

Fix StableDiffusionPipeline when `text_encoder=None` (#8297)



* update

* update

---------
Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
parent a2ecce26
...@@ -316,9 +316,10 @@ class AnimateDiffPipeline( ...@@ -316,9 +316,10 @@ class AnimateDiffPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -420,9 +420,10 @@ class AnimateDiffVideoToVideoPipeline( ...@@ -420,9 +420,10 @@ class AnimateDiffVideoToVideoPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -463,9 +463,10 @@ class StableDiffusionControlNetPipeline( ...@@ -463,9 +463,10 @@ class StableDiffusionControlNetPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -441,9 +441,10 @@ class StableDiffusionControlNetImg2ImgPipeline( ...@@ -441,9 +441,10 @@ class StableDiffusionControlNetImg2ImgPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -566,9 +566,10 @@ class StableDiffusionControlNetInpaintPipeline( ...@@ -566,9 +566,10 @@ class StableDiffusionControlNetInpaintPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -390,9 +390,10 @@ class StableDiffusionControlNetXSPipeline( ...@@ -390,9 +390,10 @@ class StableDiffusionControlNetXSPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -456,9 +456,10 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor ...@@ -456,9 +456,10 @@ class CycleDiffusionPipeline(DiffusionPipeline, TextualInversionLoaderMixin, Lor
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -426,9 +426,10 @@ class StableDiffusionInpaintPipelineLegacy( ...@@ -426,9 +426,10 @@ class StableDiffusionInpaintPipelineLegacy(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -364,9 +364,10 @@ class StableDiffusionModelEditingPipeline( ...@@ -364,9 +364,10 @@ class StableDiffusionModelEditingPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -355,9 +355,10 @@ class StableDiffusionParadigmsPipeline( ...@@ -355,9 +355,10 @@ class StableDiffusionParadigmsPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -578,9 +578,10 @@ class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline, StableDiffusionMixin ...@@ -578,9 +578,10 @@ class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline, StableDiffusionMixin
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -405,9 +405,10 @@ class LatentConsistencyModelImg2ImgPipeline( ...@@ -405,9 +405,10 @@ class LatentConsistencyModelImg2ImgPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -389,9 +389,10 @@ class LatentConsistencyModelPipeline( ...@@ -389,9 +389,10 @@ class LatentConsistencyModelPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -375,9 +375,10 @@ class PIAPipeline( ...@@ -375,9 +375,10 @@ class PIAPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -474,9 +474,10 @@ class StableDiffusionPipeline( ...@@ -474,9 +474,10 @@ class StableDiffusionPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -357,9 +357,10 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader ...@@ -357,9 +357,10 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline, TextualInversionLoader
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -517,9 +517,10 @@ class StableDiffusionImg2ImgPipeline( ...@@ -517,9 +517,10 @@ class StableDiffusionImg2ImgPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -589,9 +589,10 @@ class StableDiffusionInpaintPipeline( ...@@ -589,9 +589,10 @@ class StableDiffusionInpaintPipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -377,9 +377,10 @@ class StableDiffusionUpscalePipeline( ...@@ -377,9 +377,10 @@ class StableDiffusionUpscalePipeline(
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
...@@ -458,9 +458,10 @@ class StableUnCLIPPipeline(DiffusionPipeline, StableDiffusionMixin, TextualInver ...@@ -458,9 +458,10 @@ class StableUnCLIPPipeline(DiffusionPipeline, StableDiffusionMixin, TextualInver
negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1) negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1) negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND: if self.text_encoder is not None:
# Retrieve the original scale by scaling back the LoRA layers if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
unscale_lora_layers(self.text_encoder, lora_scale) # Retrieve the original scale by scaling back the LoRA layers
unscale_lora_layers(self.text_encoder, lora_scale)
return prompt_embeds, negative_prompt_embeds return prompt_embeds, negative_prompt_embeds
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment