File size: 1,667 Bytes
feedcc2
 
 
9d7db02
33df378
feedcc2
33df378
feedcc2
33df378
feedcc2
 
9d7db02
33df378
 
feedcc2
 
 
9d7db02
33df378
9d7db02
33df378
feedcc2
9d7db02
 
 
 
 
 
 
7949ac3
feedcc2
315ca65
 
 
9d7db02
33df378
 
315ca65
9d7db02
feedcc2
 
 
33df378
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import argparse
import subprocess
import os
import torch
from huggingface_hub import snapshot_download

# Arguments
parser = argparse.ArgumentParser()
parser.add_argument("--task", type=str, default="t2v-14B")
parser.add_argument("--size", type=str, default="832*480")
parser.add_argument("--frame_num", type=int, default=60)
parser.add_argument("--sample_steps", type=int, default=20)
parser.add_argument("--ckpt_dir", type=str, default="./Wan2.1-T2V-14B")
parser.add_argument("--offload_model", type=str, default="True")
parser.add_argument("--prompt", type=str, required=True)
args = parser.parse_args()

# Ensure the model is downloaded
if not os.path.exists(args.ckpt_dir):
    print("๐Ÿ”„ Downloading WAN 2.1 - 14B model from Hugging Face...")
    snapshot_download(repo_id="Wan-AI/Wan2.1-T2V-14B", local_dir=args.ckpt_dir)

# Free up GPU memory
if torch.cuda.is_available():
    torch.cuda.empty_cache()
    torch.backends.cudnn.benchmark = False
    torch.backends.cudnn.deterministic = True

# Run WAN 2.1 - 14B Model
command = f"python generate.py --task {args.task} --size {args.size} --frame_num {args.frame_num} --sample_steps {args.sample_steps} --ckpt_dir {args.ckpt_dir} --offload_model {args.offload_model} --prompt \"{args.prompt}\""

process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()

# Print logs for debugging
print("๐Ÿ”น Output:", stdout.decode())
print("๐Ÿ”บ Error:", stderr.decode())

# Verify if video was created
if os.path.exists("output.mp4"):
    print("โœ… Video generated successfully: output.mp4")
else:
    print("โŒ Error: Video file not found!")