Spaces:
Running
Running
Update simple_app.py
Browse files- simple_app.py +7 -10
simple_app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
import re
|
3 |
import subprocess
|
4 |
import time
|
5 |
import select
|
@@ -16,6 +16,7 @@ snapshot_download(
|
|
16 |
local_dir="./Wan2.1-T2V-1.3B"
|
17 |
)
|
18 |
print("Model downloaded successfully.")
|
|
|
19 |
def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
20 |
# Configuration:
|
21 |
total_process_steps = 11 # Total INFO messages expected
|
@@ -32,7 +33,6 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
32 |
video_progress_bar = None
|
33 |
|
34 |
# Variables for sub-step progress bar (Level 2)
|
35 |
-
# Now using 1000 ticks to represent 40 seconds (each tick = 40 ms)
|
36 |
sub_bar = None
|
37 |
sub_ticks = 0
|
38 |
sub_tick_total = 1500
|
@@ -51,8 +51,6 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
51 |
]
|
52 |
print("Starting video generation process...")
|
53 |
|
54 |
-
|
55 |
-
|
56 |
process = subprocess.Popen(command,
|
57 |
stdout=subprocess.PIPE,
|
58 |
stderr=subprocess.STDOUT,
|
@@ -74,8 +72,8 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
74 |
|
75 |
# Check for video generation progress (Level 3)
|
76 |
progress_match = progress_pattern.search(stripped_line)
|
|
|
77 |
if progress_match:
|
78 |
-
# If a sub-step bar is active, finish it before entering video phase.
|
79 |
if sub_bar is not None:
|
80 |
if sub_ticks < sub_tick_total:
|
81 |
sub_bar.update(sub_tick_total - sub_ticks)
|
@@ -112,7 +110,6 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
112 |
continue
|
113 |
else:
|
114 |
# A new relevant INFO message has arrived.
|
115 |
-
# If a sub-bar exists (whether full or not), finish it now.
|
116 |
if sub_bar is not None:
|
117 |
if sub_ticks < sub_tick_total:
|
118 |
sub_bar.update(sub_tick_total - sub_ticks)
|
@@ -135,7 +132,6 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
135 |
sub_bar.update(1)
|
136 |
sub_ticks += 1
|
137 |
sub_bar.refresh()
|
138 |
-
# If full (40 seconds reached), do not advance overall step—just remain waiting.
|
139 |
if process.poll() is not None:
|
140 |
break
|
141 |
|
@@ -148,9 +144,10 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
148 |
if sub_bar is not None:
|
149 |
sub_bar.close()
|
150 |
overall_bar.close()
|
151 |
-
|
|
|
152 |
if process.returncode == 0:
|
153 |
-
print("
|
154 |
return "generated_video.mp4"
|
155 |
else:
|
156 |
print("Error executing command.")
|
@@ -171,4 +168,4 @@ with gr.Blocks() as demo:
|
|
171 |
outputs=[video_res]
|
172 |
)
|
173 |
|
174 |
-
demo.queue().launch(show_error=True, show_api=False, ssr_mode=False)
|
|
|
1 |
import gradio as gr
|
2 |
+
import re
|
3 |
import subprocess
|
4 |
import time
|
5 |
import select
|
|
|
16 |
local_dir="./Wan2.1-T2V-1.3B"
|
17 |
)
|
18 |
print("Model downloaded successfully.")
|
19 |
+
|
20 |
def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
21 |
# Configuration:
|
22 |
total_process_steps = 11 # Total INFO messages expected
|
|
|
33 |
video_progress_bar = None
|
34 |
|
35 |
# Variables for sub-step progress bar (Level 2)
|
|
|
36 |
sub_bar = None
|
37 |
sub_ticks = 0
|
38 |
sub_tick_total = 1500
|
|
|
51 |
]
|
52 |
print("Starting video generation process...")
|
53 |
|
|
|
|
|
54 |
process = subprocess.Popen(command,
|
55 |
stdout=subprocess.PIPE,
|
56 |
stderr=subprocess.STDOUT,
|
|
|
72 |
|
73 |
# Check for video generation progress (Level 3)
|
74 |
progress_match = progress_pattern.search(stripped_line)
|
75 |
+
|
76 |
if progress_match:
|
|
|
77 |
if sub_bar is not None:
|
78 |
if sub_ticks < sub_tick_total:
|
79 |
sub_bar.update(sub_tick_total - sub_ticks)
|
|
|
110 |
continue
|
111 |
else:
|
112 |
# A new relevant INFO message has arrived.
|
|
|
113 |
if sub_bar is not None:
|
114 |
if sub_ticks < sub_tick_total:
|
115 |
sub_bar.update(sub_tick_total - sub_ticks)
|
|
|
132 |
sub_bar.update(1)
|
133 |
sub_ticks += 1
|
134 |
sub_bar.refresh()
|
|
|
135 |
if process.poll() is not None:
|
136 |
break
|
137 |
|
|
|
144 |
if sub_bar is not None:
|
145 |
sub_bar.close()
|
146 |
overall_bar.close()
|
147 |
+
|
148 |
+
# Add log for successful video generation
|
149 |
if process.returncode == 0:
|
150 |
+
print("Video generation completed successfully.")
|
151 |
return "generated_video.mp4"
|
152 |
else:
|
153 |
print("Error executing command.")
|
|
|
168 |
outputs=[video_res]
|
169 |
)
|
170 |
|
171 |
+
demo.queue().launch(show_error=True, show_api=False, ssr_mode=False)
|