Spaces:
Running
Running
| import torch | |
| from diffusers import CogVideoXImageToVideoPipeline | |
| from diffusers.utils import export_to_video, load_image | |
| prompt = "A dragon is flipping its wings" | |
| image = load_image(image="/hpc2hdd/home/lwang592/projects/CogVideo/sat/configs/i2v/Dragon.jpg") | |
| pipe = CogVideoXImageToVideoPipeline.from_pretrained( | |
| "THUDM/CogVideoX-5b-I2V", | |
| torch_dtype=torch.bfloat16 | |
| ) | |
| pipe.enable_sequential_cpu_offload() | |
| pipe.vae.enable_tiling() | |
| pipe.vae.enable_slicing() | |
| video = pipe( | |
| prompt=prompt, | |
| image=image, | |
| num_videos_per_prompt=1, | |
| num_inference_steps=50, | |
| num_frames=13, | |
| guidance_scale=6, | |
| generator=torch.Generator(device="cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(video, "output.mp4", fps=8) | |