File size: 1,345 Bytes
4e424ea |
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 45 46 47 |
import gradio as gr
import subprocess
from huggingface_hub import snapshot_download
#Download model
snapshot_download(
repo_id = "Wan-AI/Wan2.1-T2V-1.3B",
local_dir = "./Wan2.1-T2V-1.3B"
)
def infer(prompt):
prompt = ""Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.""
command = [
"python", "-m", "generate.py",
"--task", "t2v-1.3B",
"--size", "832*480",
"--ckpt_dir", "./Wan2.1-T2V-1.3B",
"--sample_shift", "8",
"--sample_guide_scale", "6",
"--prompt", f"{prompt}",
"--save_file", "generated_video.mp4"
]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode == 0:
print("Command executed successfully.")
return "./tmp/"generated_video.mp4""
else:
print("Error executing command.")
raise gr.Error("Error executing command")
with gr.Blocks() as demo:
with gr.Column():
gr.Markdown("# Wan 2.1")
prompt = gr.Textbox(labe="Prompt")
submit_btn = gr.Button("Submit")
video_res = gr.Video(label="Generated Video")
submit_btn.click(
fn = infer,
inputs = [prompt],
outputs = [video_res]
)
demo.queue().launch(show_error=True, show_api=False, ssr_mode=False) |