Spaces:
Paused
Paused
| import subprocess, shutil, tempfile, os | |
| from pathlib import Path | |
| BASE = Path(__file__).resolve().parent | |
| CKPT_VACE = BASE / "Wan2.1-VACE-1.3B" | |
| CKPT_FLF = BASE / "Wan2.1-FLF2V-14B-720P" | |
| def run_cmd(cmd): | |
| subprocess.run(cmd, check=True) | |
| def generate_video(ref_img, first_frame, last_frame, output_path): | |
| run_cmd([ | |
| "python", "vace/vace_preprocess.py", | |
| "--task", "extension", | |
| "--mode", "firstlastframe", | |
| "--image", f"{first_frame},{last_frame}", | |
| "--expand_num", "240" | |
| ]) | |
| run_cmd([ | |
| "python", "generate.py", | |
| "--task", "flf2v-14B", | |
| "--size", "1280*720", | |
| "--ckpt_dir", str(CKPT_FLF), | |
| "--src_ref_images", ref_img, | |
| "--src_video", "processed/src_video.mp4", | |
| "--fps", "24", | |
| "--offload_model", "True", | |
| "--t5_cpu" | |
| ]) | |
| shutil.move("results/final.mp4", output_path) | |
| def generate_image(ref_img, prompt, output_path): | |
| run_cmd([ | |
| "python", "generate.py", | |
| "--task", "vace-1.3B", | |
| "--size", "832*480", | |
| "--ckpt_dir", str(CKPT_VACE), | |
| "--src_ref_images", ref_img, | |
| "--frame_num", "1", | |
| "--prompt", prompt or " " | |
| ]) | |
| shutil.move("results/final_frame000.png", output_path) |