mirror of
https://git.datalinker.icu/kijai/ComfyUI-CogVideoXWrapper.git
synced 2026-05-02 22:20:08 +08:00
Error on too long prompts.
This commit is contained in:
parent
a995247624
commit
42c46b76e1
8
nodes.py
8
nodes.py
@ -751,14 +751,18 @@ class CogVideoTextEncode:
|
|||||||
CATEGORY = "CogVideoWrapper"
|
CATEGORY = "CogVideoWrapper"
|
||||||
|
|
||||||
def process(self, clip, prompt, strength=1.0, force_offload=True):
|
def process(self, clip, prompt, strength=1.0, force_offload=True):
|
||||||
|
max_tokens = 226
|
||||||
load_device = mm.text_encoder_device()
|
load_device = mm.text_encoder_device()
|
||||||
offload_device = mm.text_encoder_offload_device()
|
offload_device = mm.text_encoder_offload_device()
|
||||||
clip.tokenizer.t5xxl.pad_to_max_length = True
|
clip.tokenizer.t5xxl.pad_to_max_length = True
|
||||||
clip.tokenizer.t5xxl.max_length = 226
|
clip.tokenizer.t5xxl.max_length = max_tokens
|
||||||
clip.cond_stage_model.to(load_device)
|
clip.cond_stage_model.to(load_device)
|
||||||
tokens = clip.tokenize(prompt, return_word_ids=True)
|
tokens = clip.tokenize(prompt, return_word_ids=True)
|
||||||
|
|
||||||
embeds = clip.encode_from_tokens(tokens, return_pooled=False, return_dict=False)
|
embeds = clip.encode_from_tokens(tokens, return_pooled=False, return_dict=False)
|
||||||
|
|
||||||
|
if embeds.shape[1] > 226:
|
||||||
|
raise ValueError(f"Prompt is too long, max tokens supported is {max_tokens} or less, got {embeds.shape[1]}")
|
||||||
embeds *= strength
|
embeds *= strength
|
||||||
if force_offload:
|
if force_offload:
|
||||||
clip.cond_stage_model.to(offload_device)
|
clip.cond_stage_model.to(offload_device)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user