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

Function encode_prompt

diffusers/examples/dreambooth/train_dreambooth.py:788–803  ·  view source on GitHub ↗
(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None)

Source from the content-addressed store, hash-verified

786
787
788def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None):
789 text_input_ids = input_ids.to(text_encoder.device)
790
791 if text_encoder_use_attention_mask:
792 attention_mask = attention_mask.to(text_encoder.device)
793 else:
794 attention_mask = None
795
796 prompt_embeds = text_encoder(
797 text_input_ids,
798 attention_mask=attention_mask,
799 return_dict=False,
800 )
801 prompt_embeds = prompt_embeds[0]
802
803 return prompt_embeds
804
805
806def 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