(
tokenizer: T5Tokenizer,
text_encoder: T5EncoderModel,
prompt: Union[str, List[str]],
num_videos_per_prompt: int = 1,
max_sequence_length: int = 226,
device: Optional[torch.device] = None,
dtype: Optional[torch.dtype] = None,
text_input_ids=None,
)
| 822 | |
| 823 | |
| 824 | def encode_prompt( |
| 825 | tokenizer: T5Tokenizer, |
| 826 | text_encoder: T5EncoderModel, |
| 827 | prompt: Union[str, List[str]], |
| 828 | num_videos_per_prompt: int = 1, |
| 829 | max_sequence_length: int = 226, |
| 830 | device: Optional[torch.device] = None, |
| 831 | dtype: Optional[torch.dtype] = None, |
| 832 | text_input_ids=None, |
| 833 | ): |
| 834 | prompt = [prompt] if isinstance(prompt, str) else prompt |
| 835 | prompt_embeds = _get_t5_prompt_embeds( |
| 836 | tokenizer, |
| 837 | text_encoder, |
| 838 | prompt=prompt, |
| 839 | num_videos_per_prompt=num_videos_per_prompt, |
| 840 | max_sequence_length=max_sequence_length, |
| 841 | device=device, |
| 842 | dtype=dtype, |
| 843 | text_input_ids=text_input_ids, |
| 844 | ) |
| 845 | return prompt_embeds |
| 846 | |
| 847 | |
| 848 | def compute_prompt_embeddings( |
no test coverage detected