fffiloni commited on
Commit
b7b7a86
·
verified ·
1 Parent(s): 7bedcdd

Update simple_app.py

Browse files
Files changed (1) hide show
  1. simple_app.py +5 -4
simple_app.py CHANGED
@@ -37,17 +37,18 @@ 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
- # Try to parse progress info from the line
41
  match = progress_pattern.search(line)
42
  if match:
 
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")
47
- # Update the progress bar only if progress has advanced
48
  progress_bar.update(current - progress_bar.n)
 
 
49
  else:
50
- # Print any other log lines as they are
51
  print(line, end="")
52
 
53
  process.wait()
 
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()