fffiloni commited on
Commit
6c641ac
·
verified ·
1 Parent(s): b7b7a86

Update simple_app.py

Browse files
Files changed (1) hide show
  1. simple_app.py +8 -5
simple_app.py CHANGED
@@ -37,19 +37,22 @@ def infer(prompt, progress=gr.Progress(track_tqdm=True)):
37
  progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
38
 
39
  for line in iter(process.stdout.readline, ''):
40
- match = progress_pattern.search(line)
 
 
 
 
 
 
41
  if match:
42
- # Update tqdm without printing the line to logs
43
  current = int(match.group(2))
44
  total = int(match.group(3))
45
  if progress_bar is None:
46
  progress_bar = tqdm(total=total, desc="Video Generation Progress", leave=True)
47
  progress_bar.update(current - progress_bar.n)
48
- # Optionally, refresh the tqdm display without a newline:
49
  progress_bar.refresh()
50
  else:
51
- # For non-progress lines, print them normally
52
- print(line, end="")
53
 
54
  process.wait()
55
  if progress_bar is not None:
 
37
  progress_pattern = re.compile(r"(\d+)%\|.*\| (\d+)/(\d+)")
38
 
39
  for line in iter(process.stdout.readline, ''):
40
+ # Remove any carriage returns/newlines from the line
41
+ stripped_line = line.strip()
42
+ # Skip empty lines
43
+ if not stripped_line:
44
+ continue
45
+
46
+ match = progress_pattern.search(stripped_line)
47
  if match:
 
48
  current = int(match.group(2))
49
  total = int(match.group(3))
50
  if progress_bar is None:
51
  progress_bar = tqdm(total=total, desc="Video Generation Progress", leave=True)
52
  progress_bar.update(current - progress_bar.n)
 
53
  progress_bar.refresh()
54
  else:
55
+ print(line, end="") # Print other output normally
 
56
 
57
  process.wait()
58
  if progress_bar is not None: