mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
fix(pipelines): restore clip-skip text encoding for transformers 5.6+
The vendored encode_prompt copies in the PAG, APG, ControlNet-XS and differential diffusion pipelines dereference the .text_model wrapper that transformers 5.6 removed from CLIPTextModel, so their clip-skip path crashes on SD1.5 and SDXL TE1. Apply the same getattr(te, 'text_model', te) fix as the core parser. Mirrors upstream diffusers, which still carries this deref in pipeline encode_prompt; only the single-file loader was fixed there.
This commit is contained in:
@@ -404,7 +404,8 @@ class StableDiffusionPipelineAPG(
|
||||
# representations. The `last_hidden_states` that we typically use for
|
||||
# obtaining the final prompt representations passes through the LayerNorm
|
||||
# layer.
|
||||
prompt_embeds = self.text_encoder.text_model.final_layer_norm(prompt_embeds)
|
||||
# transformers >=5.6 flattened CLIPTextModel; CLIPTextModelWithProjection still nests it under .text_model
|
||||
prompt_embeds = getattr(self.text_encoder, 'text_model', self.text_encoder).final_layer_norm(prompt_embeds)
|
||||
|
||||
if self.text_encoder is not None:
|
||||
prompt_embeds_dtype = self.text_encoder.dtype
|
||||
|
||||
@@ -1321,7 +1321,8 @@ class StableDiffusionControlNetXSPipeline(
|
||||
# representations. The `last_hidden_states` that we typically use for
|
||||
# obtaining the final prompt representations passes through the LayerNorm
|
||||
# layer.
|
||||
prompt_embeds = self.text_encoder.text_model.final_layer_norm(prompt_embeds)
|
||||
# transformers >=5.6 flattened CLIPTextModel; CLIPTextModelWithProjection still nests it under .text_model
|
||||
prompt_embeds = getattr(self.text_encoder, 'text_model', self.text_encoder).final_layer_norm(prompt_embeds)
|
||||
|
||||
if self.text_encoder is not None:
|
||||
prompt_embeds_dtype = self.text_encoder.dtype
|
||||
|
||||
@@ -619,7 +619,8 @@ class StableDiffusionPAGPipeline(
|
||||
# representations. The `last_hidden_states` that we typically use for
|
||||
# obtaining the final prompt representations passes through the LayerNorm
|
||||
# layer.
|
||||
prompt_embeds = self.text_encoder.text_model.final_layer_norm(prompt_embeds)
|
||||
# transformers >=5.6 flattened CLIPTextModel; CLIPTextModelWithProjection still nests it under .text_model
|
||||
prompt_embeds = getattr(self.text_encoder, 'text_model', self.text_encoder).final_layer_norm(prompt_embeds)
|
||||
|
||||
if self.text_encoder is not None:
|
||||
prompt_embeds_dtype = self.text_encoder.dtype
|
||||
|
||||
@@ -1546,7 +1546,8 @@ class StableDiffusionDiffImg2ImgPipeline(DiffusionPipeline):
|
||||
# representations. The `last_hidden_states` that we typically use for
|
||||
# obtaining the final prompt representations passes through the LayerNorm
|
||||
# layer.
|
||||
prompt_embeds = self.text_encoder.text_model.final_layer_norm(prompt_embeds)
|
||||
# transformers >=5.6 flattened CLIPTextModel; CLIPTextModelWithProjection still nests it under .text_model
|
||||
prompt_embeds = getattr(self.text_encoder, 'text_model', self.text_encoder).final_layer_norm(prompt_embeds)
|
||||
|
||||
if self.text_encoder is not None:
|
||||
prompt_embeds_dtype = self.text_encoder.dtype
|
||||
|
||||
Reference in New Issue
Block a user