Update simple_app.py
Browse files- simple_app.py +18 -11
simple_app.py
CHANGED
|
@@ -19,9 +19,7 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
| 19 |
overall_bar = tqdm(total=relevant_steps, desc="Overall Process", position=1, dynamic_ncols=True, leave=True)
|
| 20 |
processed_steps = 0
|
| 21 |
|
| 22 |
-
# Regex to capture video generation progress lines (e.g., "10%|...| 5/50")
|
| 23 |
progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
|
| 24 |
-
|
| 25 |
gen_progress_bar = None
|
| 26 |
|
| 27 |
command = [
|
|
@@ -44,12 +42,14 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
| 44 |
bufsize=1 # line-buffered
|
| 45 |
)
|
| 46 |
|
|
|
|
|
|
|
| 47 |
for line in iter(process.stdout.readline, ''):
|
| 48 |
stripped_line = line.strip()
|
| 49 |
if not stripped_line:
|
| 50 |
continue
|
| 51 |
|
| 52 |
-
#
|
| 53 |
progress_match = progress_pattern.search(stripped_line)
|
| 54 |
if progress_match:
|
| 55 |
current = int(progress_match.group(2))
|
|
@@ -60,22 +60,29 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
|
|
| 60 |
gen_progress_bar.refresh()
|
| 61 |
continue
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
if "
|
| 65 |
-
# Split on "INFO:" (in a case-insensitive manner) to get the text after it.
|
| 66 |
parts = stripped_line.split("INFO:", 1)
|
| 67 |
msg = parts[1].strip() if len(parts) > 1 else ""
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
if processed_steps < irrelevant_steps:
|
| 72 |
processed_steps += 1
|
| 73 |
else:
|
| 74 |
overall_bar.update(1)
|
| 75 |
percentage = (overall_bar.n / overall_bar.total) * 100
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
overall_bar.refresh()
|
|
|
|
| 79 |
else:
|
| 80 |
tqdm.write(stripped_line)
|
| 81 |
|
|
|
|
| 19 |
overall_bar = tqdm(total=relevant_steps, desc="Overall Process", position=1, dynamic_ncols=True, leave=True)
|
| 20 |
processed_steps = 0
|
| 21 |
|
|
|
|
| 22 |
progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
|
|
|
|
| 23 |
gen_progress_bar = None
|
| 24 |
|
| 25 |
command = [
|
|
|
|
| 42 |
bufsize=1 # line-buffered
|
| 43 |
)
|
| 44 |
|
| 45 |
+
last_msg = "" # To store the last INFO message
|
| 46 |
+
|
| 47 |
for line in iter(process.stdout.readline, ''):
|
| 48 |
stripped_line = line.strip()
|
| 49 |
if not stripped_line:
|
| 50 |
continue
|
| 51 |
|
| 52 |
+
# Match video generation progress (e.g., "10%|...| 5/50")
|
| 53 |
progress_match = progress_pattern.search(stripped_line)
|
| 54 |
if progress_match:
|
| 55 |
current = int(progress_match.group(2))
|
|
|
|
| 60 |
gen_progress_bar.refresh()
|
| 61 |
continue
|
| 62 |
|
| 63 |
+
# Check for INFO lines and extract the message
|
| 64 |
+
if "INFO:" in stripped_line:
|
|
|
|
| 65 |
parts = stripped_line.split("INFO:", 1)
|
| 66 |
msg = parts[1].strip() if len(parts) > 1 else ""
|
| 67 |
+
|
| 68 |
+
# Debugging print to check extracted message
|
| 69 |
+
tqdm.write(f"Extracted INFO message: '{msg}'")
|
| 70 |
+
|
| 71 |
+
# Skip first three steps
|
| 72 |
if processed_steps < irrelevant_steps:
|
| 73 |
processed_steps += 1
|
| 74 |
else:
|
| 75 |
overall_bar.update(1)
|
| 76 |
percentage = (overall_bar.n / overall_bar.total) * 100
|
| 77 |
+
last_msg = msg # Store last INFO message
|
| 78 |
+
|
| 79 |
+
# Debugging print before updating description
|
| 80 |
+
tqdm.write(f"Updating description: Overall Process - {percentage:.1f}% | {last_msg}")
|
| 81 |
+
|
| 82 |
+
# Update progress bar description with INFO message
|
| 83 |
+
overall_bar.set_description(f"Overall Process - {percentage:.1f}% | {last_msg}")
|
| 84 |
overall_bar.refresh()
|
| 85 |
+
|
| 86 |
else:
|
| 87 |
tqdm.write(stripped_line)
|
| 88 |
|