"""Encodes Taurus Animate's fixed prompt with UMT5-XXL, in a process of its own, and saves the embeddings. Run by app.py at start-up: `python encode_prompt.py `. It lives apart from the Space's main process because that process is the one ZeroGPU forks its GPU worker from, and a big multi-threaded CPU run of torch there has left the worker unable to see the GPU ("No CUDA GPUs are available"). This file never imports `spaces`, so torch here is plain torch. """ import sys import torch from diffusers import WanImageToVideoPipeline import core def main(wan_dir, out): pipe = WanImageToVideoPipeline.from_pretrained(wan_dir, transformer=None, vae=None, torch_dtype=torch.bfloat16) with torch.inference_mode(): positive, negative = pipe.encode_prompt( prompt=core.POSITIVE, negative_prompt=core.NEGATIVE, do_classifier_free_guidance=True, num_videos_per_prompt=1, device=torch.device("cpu")) torch.save({"positive": positive.cpu(), "negative": negative.cpu()}, out) if __name__ == "__main__": main(sys.argv[1], sys.argv[2])