Skip to content

Instantly share code, notes, and snippets.

@lucataco
Last active March 5, 2025 18:41
Show Gist options
  • Save lucataco/249cba216fc1d1304e8faf51dfed1a3a to your computer and use it in GitHub Desktop.
Save lucataco/249cba216fc1d1304e8faf51dfed1a3a to your computer and use it in GitHub Desktop.
Run Wan2.1-T2V-1.3B-Diffusers on your Mac
# Setup:
# conda create -n wan python=3.10
# conda activate wan
# pip3 install torch torchvision torchaudio
# pip install git+https://github.com/huggingface/diffusers.git@3ee899fa0c0a443db371848a87582b2e2295852d
# pip install accelerate==1.4.0
# pip install transformers==4.49.0
# pip install ftfy==6.3.1
import torch
from diffusers.models import AutoencoderKLWan
from diffusers import WanPipeline
from diffusers.utils import export_to_video
# Available models: Wan-AI/Wan2.1-T2V-14B-Diffusers, Wan-AI/Wan2.1-T2V-1.3B-Diffusers
model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
prompt = "A cat walks on the grass, realistic"
negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"
output = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
height=480,
width=832,
num_frames=81,
guidance_scale=5.0
).frames[0]
export_to_video(output, "output.mp4", fps=15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment