mirror of
https://github.com/vladmandic/automatic
synced 2026-09-10 14:58:44 +02:00
fix(prompt): restore textual inversion on clip-skip>=2
transformers 5.6 flattened CLIPTextModel, removing the .text_model wrapper that compel_hijack and the xhinker parser dereference on the normalized clip-skip path. On SD1.5 at clip-skip >= 2 this raised AttributeError, which processing_prompt caught and silently fell back to fixed-attention encoding, dropping textual inversion and prompt weighting. Resolve the submodule via getattr(te, 'text_model', te), correct for flattened CLIPTextModel, CLIPTextModelWithProjection (still nested), and transformers < 5.6.
This commit is contained in:
@@ -327,7 +327,9 @@ def compel_hijack(self, token_ids: torch.Tensor, attention_mask: torch.Tensor |
|
||||
else:
|
||||
hidden_state = text_encoder_output.hidden_states[-clip_skip]
|
||||
if normalized:
|
||||
hidden_state = self.text_encoder.text_model.final_layer_norm(hidden_state)
|
||||
# transformers >=5.6 flattened CLIPTextModel; CLIPTextModelWithProjection still nests it under .text_model
|
||||
text_model = getattr(self.text_encoder, 'text_model', self.text_encoder)
|
||||
hidden_state = text_model.final_layer_norm(hidden_state)
|
||||
return hidden_state
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user