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

Function tokenize_prompt

diffusers/examples/dreambooth/train_dreambooth.py:771–785  ·  view source on GitHub ↗
(tokenizer, prompt, tokenizer_max_length=None)

Source from the content-addressed store, hash-verified

769
770
771def tokenize_prompt(tokenizer, prompt, tokenizer_max_length=None):
772 if tokenizer_max_length is not None:
773 max_length = tokenizer_max_length
774 else:
775 max_length = tokenizer.model_max_length
776
777 text_inputs = tokenizer(
778 prompt,
779 truncation=True,
780 padding="max_length",
781 max_length=max_length,
782 return_tensors="pt",
783 )
784
785 return text_inputs
786
787
788def encode_prompt(text_encoder, input_ids, attention_mask, text_encoder_use_attention_mask=None):

Callers 2

__getitem__Method · 0.70
compute_text_embeddingsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected