fffiloni commited on
Commit
91dbeb2
·
verified ·
1 Parent(s): 72a0d14

Update simple_app.py

Browse files
Files changed (1) hide show
  1. simple_app.py +8 -9
simple_app.py CHANGED
@@ -16,7 +16,7 @@ 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
- # 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
 
@@ -24,7 +24,7 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
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,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 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,20 +68,19 @@ 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 (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:
75
  processed_steps += 1
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.
85
  tqdm.write(stripped_line)
86
 
87
  process.wait()
 
16
  irrelevant_steps = 4
17
  relevant_steps = total_process_steps - irrelevant_steps # 7 steps
18
 
19
+ # Create an overall progress bar for the relevant steps.
20
  overall_bar = tqdm(total=relevant_steps, desc="Overall Process", position=1, dynamic_ncols=True, leave=True)
21
  processed_steps = 0
22
 
 
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 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
  info_match = info_pattern.search(stripped_line)
69
  if info_match:
70
  msg = info_match.group(1)
71
+ # Print the raw log line.
72
  tqdm.write(stripped_line)
73
+ # For relevant steps (after the first three), update the overall progress bar.
74
  if processed_steps < irrelevant_steps:
75
  processed_steps += 1
76
  else:
77
  overall_bar.update(1)
78
  percentage = (overall_bar.n / overall_bar.total) * 100
79
+ # Directly insert the INFO message in the description.
80
+ overall_bar.set_description(f"Overall Process - {percentage:.1f}% | {msg}")
 
81
  overall_bar.refresh()
82
  else:
83
+ # For any other line, simply print it.
84
  tqdm.write(stripped_line)
85
 
86
  process.wait()