Spaces:
Paused
Paused
Update simple_app.py
Browse files- simple_app.py +8 -6
simple_app.py
CHANGED
@@ -16,15 +16,15 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
16 |
irrelevant_steps = 4
|
17 |
relevant_steps = total_process_steps - irrelevant_steps # 7 steps
|
18 |
|
19 |
-
#
|
20 |
overall_bar = tqdm(total=relevant_steps, desc="Overall Process", position=1, dynamic_ncols=True, leave=True)
|
21 |
processed_steps = 0
|
22 |
|
23 |
# Regex to extract the INFO message (everything after "INFO:")
|
24 |
info_pattern = re.compile(r"\[.*?\]\s+INFO:\s+(.*)")
|
25 |
-
# Regex to capture video generation progress lines (e.g
|
26 |
progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
|
27 |
-
|
28 |
gen_progress_bar = None
|
29 |
|
30 |
command = [
|
@@ -59,7 +59,7 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
59 |
total = int(progress_match.group(3))
|
60 |
if gen_progress_bar is None:
|
61 |
gen_progress_bar = tqdm(total=total, desc="Video Generation", position=0, dynamic_ncols=True, leave=True)
|
62 |
-
# Update video generation progress
|
63 |
gen_progress_bar.update(current - gen_progress_bar.n)
|
64 |
gen_progress_bar.refresh()
|
65 |
continue # Skip further processing for progress lines
|
@@ -68,7 +68,7 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
68 |
info_match = info_pattern.search(stripped_line)
|
69 |
if info_match:
|
70 |
msg = info_match.group(1)
|
71 |
-
# Always print the log line.
|
72 |
tqdm.write(stripped_line)
|
73 |
# For relevant steps (i.e. after the first three), update the overall progress.
|
74 |
if processed_steps < irrelevant_steps:
|
@@ -76,7 +76,9 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
76 |
else:
|
77 |
overall_bar.update(1)
|
78 |
percentage = (overall_bar.n / overall_bar.total) * 100
|
79 |
-
|
|
|
|
|
80 |
overall_bar.refresh()
|
81 |
else:
|
82 |
# For any other line, print it.
|
|
|
16 |
irrelevant_steps = 4
|
17 |
relevant_steps = total_process_steps - irrelevant_steps # 7 steps
|
18 |
|
19 |
+
# Create an overall progress bar for the 9 relevant steps.
|
20 |
overall_bar = tqdm(total=relevant_steps, desc="Overall Process", position=1, dynamic_ncols=True, leave=True)
|
21 |
processed_steps = 0
|
22 |
|
23 |
# Regex to extract the INFO message (everything after "INFO:")
|
24 |
info_pattern = re.compile(r"\[.*?\]\s+INFO:\s+(.*)")
|
25 |
+
# Regex to capture video generation progress lines (e.g., " 10%|...| 5/50")
|
26 |
progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
|
27 |
+
|
28 |
gen_progress_bar = None
|
29 |
|
30 |
command = [
|
|
|
59 |
total = int(progress_match.group(3))
|
60 |
if gen_progress_bar is None:
|
61 |
gen_progress_bar = tqdm(total=total, desc="Video Generation", position=0, dynamic_ncols=True, leave=True)
|
62 |
+
# Update the video generation progress bar
|
63 |
gen_progress_bar.update(current - gen_progress_bar.n)
|
64 |
gen_progress_bar.refresh()
|
65 |
continue # Skip further processing for progress lines
|
|
|
68 |
info_match = info_pattern.search(stripped_line)
|
69 |
if info_match:
|
70 |
msg = info_match.group(1)
|
71 |
+
# Always print the log line (using tqdm.write so it doesn't interfere with the bars)
|
72 |
tqdm.write(stripped_line)
|
73 |
# For relevant steps (i.e. after the first three), update the overall progress.
|
74 |
if processed_steps < irrelevant_steps:
|
|
|
76 |
else:
|
77 |
overall_bar.update(1)
|
78 |
percentage = (overall_bar.n / overall_bar.total) * 100
|
79 |
+
# Update the description for the left part and set the postfix to the INFO message.
|
80 |
+
overall_bar.set_description(f"Overall Process - {percentage:.1f}%")
|
81 |
+
overall_bar.set_postfix_str(msg)
|
82 |
overall_bar.refresh()
|
83 |
else:
|
84 |
# For any other line, print it.
|