fffiloni commited on
Commit
4e424ea
·
verified ·
1 Parent(s): e09c2dd

Create simple_app.py

Browse files
Files changed (1) hide show
  1. simple_app.py +47 -0
simple_app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ from huggingface_hub import snapshot_download
4
+
5
+ #Download model
6
+ snapshot_download(
7
+ repo_id = "Wan-AI/Wan2.1-T2V-1.3B",
8
+ local_dir = "./Wan2.1-T2V-1.3B"
9
+ )
10
+
11
+ def infer(prompt):
12
+ prompt = ""Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage.""
13
+
14
+ command = [
15
+ "python", "-m", "generate.py",
16
+ "--task", "t2v-1.3B",
17
+ "--size", "832*480",
18
+ "--ckpt_dir", "./Wan2.1-T2V-1.3B",
19
+ "--sample_shift", "8",
20
+ "--sample_guide_scale", "6",
21
+ "--prompt", f"{prompt}",
22
+ "--save_file", "generated_video.mp4"
23
+ ]
24
+
25
+ result = subprocess.run(command, capture_output=True, text=True)
26
+
27
+ if result.returncode == 0:
28
+ print("Command executed successfully.")
29
+ return "./tmp/"generated_video.mp4""
30
+ else:
31
+ print("Error executing command.")
32
+ raise gr.Error("Error executing command")
33
+
34
+ with gr.Blocks() as demo:
35
+ with gr.Column():
36
+ gr.Markdown("# Wan 2.1")
37
+ prompt = gr.Textbox(labe="Prompt")
38
+ submit_btn = gr.Button("Submit")
39
+ video_res = gr.Video(label="Generated Video")
40
+
41
+ submit_btn.click(
42
+ fn = infer,
43
+ inputs = [prompt],
44
+ outputs = [video_res]
45
+ )
46
+
47
+ demo.queue().launch(show_error=True, show_api=False, ssr_mode=False)