MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / encode_prompt

Function encode_prompt

diffusers/examples/dreambooth/train_dreambooth_lora.py:717–732  ·  view source on GitHub ↗
(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None)

Source from the content-addressed store, hash-verified

715
716
717def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None):
718 text_input_ids = input_ids.to(text_encoder.device)
719
720 if text_encoder_use_attention_mask:
721 attention_mask = attention_mask.to(text_encoder.device)
722 else:
723 attention_mask = None
724
725 prompt_embeds = text_encoder(
726 text_input_ids,
727 attention_mask=attention_mask,
728 return_dict=False,
729 )
730 prompt_embeds = prompt_embeds[0]
731
732 return prompt_embeds
733
734
735def main(args):

Callers 2

compute_text_embeddingsFunction · 0.70
mainFunction · 0.70

Calls 2

text_encoderFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected