Skip to content

Commit 5084074

Browse files
fix: add safe dtype access in get_weighted_text_embeddings_sd3
Add hasattr check before accessing pipe.text_encoder.dtype to prevent AttributeError if text_encoder doesn't exist. Falls back to text_encoder_2 or torch.float32 as default.
1 parent 9da5ce2 commit 5084074

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/oneiro/pipelines/long_prompt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,13 @@ def get_weighted_text_embeddings_sd3(
819819
negative_pooled_prompt_embeds_1 = None
820820
negative_pooled_prompt_embeds_2 = None
821821

822-
dtype = pipe.text_encoder.dtype
822+
# Determine dtype - use text_encoder if available, otherwise use text_encoder_2's dtype
823+
if hasattr(pipe, "text_encoder") and pipe.text_encoder is not None:
824+
dtype = pipe.text_encoder.dtype
825+
elif hasattr(pipe, "text_encoder_2") and pipe.text_encoder_2 is not None:
826+
dtype = pipe.text_encoder_2.dtype
827+
else:
828+
dtype = torch.float32 # Fallback default
823829

824830
for i in range(len(prompt_chunks_1)):
825831
# Positive - encoder 1

0 commit comments

Comments
 (0)