#!/usr/bin/env python3 """Encode one prompt with LingBot's umT5 encoder: encode_prompt.py "".""" import sys import torch sys.path.insert(0, "/work/lbv2") from safetensors.torch import save_file # noqa: E402 from wan.modules.t5 import T5EncoderModel # noqa: E402 ckpt, tok, out, prompt = sys.argv[1:5] enc = T5EncoderModel(text_len=512, dtype=torch.bfloat16, device=torch.device("cuda"), checkpoint_path=ckpt, tokenizer_path=tok) with torch.no_grad(): e = enc([prompt], torch.device("cuda"))[0] print("prompt tokens", tuple(e.shape), "std", float(e.float().std())) save_file({"prompt_embeds": e.float().cpu()}, out, metadata={"prompt": prompt})