Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,12 @@ import tempfile
|
|
6 |
import huggingface_hub
|
7 |
import subprocess
|
8 |
import threading
|
|
|
9 |
|
10 |
-
def stream_output(pipe):
|
11 |
for line in iter(pipe.readline, ''):
|
12 |
print(line, end='')
|
|
|
13 |
|
14 |
HF_TKN = os.environ.get("GATED_HF_TOKEN")
|
15 |
huggingface_hub.login(token=HF_TKN)
|
@@ -77,7 +79,7 @@ def check_for_mp4_in_outputs():
|
|
77 |
else:
|
78 |
return None
|
79 |
|
80 |
-
def infer(ref_video_in, ref_image_in, progress=gr.Progress()):
|
81 |
# check if 'outputs' dir exists and empty it if necessary
|
82 |
check_outputs_folder('./outputs')
|
83 |
|
@@ -132,9 +134,13 @@ def infer(ref_video_in, ref_image_in, progress=gr.Progress()):
|
|
132 |
command = ['python', 'inference.py', '--inference_config', file_path]
|
133 |
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
|
134 |
|
|
|
|
|
|
|
135 |
# Create threads to handle stdout and stderr
|
136 |
-
stdout_thread = threading.Thread(target=stream_output, args=(process.stdout,))
|
137 |
-
stderr_thread = threading.Thread(target=stream_output, args=(process.stderr,))
|
|
|
138 |
|
139 |
# Start the threads
|
140 |
stdout_thread.start()
|
@@ -144,6 +150,9 @@ def infer(ref_video_in, ref_image_in, progress=gr.Progress()):
|
|
144 |
process.wait()
|
145 |
stdout_thread.join()
|
146 |
stderr_thread.join()
|
|
|
|
|
|
|
147 |
|
148 |
print("Inference script finished with return code:", process.returncode)
|
149 |
|
|
|
6 |
import huggingface_hub
|
7 |
import subprocess
|
8 |
import threading
|
9 |
+
from tqdm import tqdm
|
10 |
|
11 |
+
def stream_output(pipe, progress_bar):
|
12 |
for line in iter(pipe.readline, ''):
|
13 |
print(line, end='')
|
14 |
+
progress_bar.update(1)
|
15 |
|
16 |
HF_TKN = os.environ.get("GATED_HF_TOKEN")
|
17 |
huggingface_hub.login(token=HF_TKN)
|
|
|
79 |
else:
|
80 |
return None
|
81 |
|
82 |
+
def infer(ref_video_in, ref_image_in, progress=gr.Progress(track_tqdm=True)):
|
83 |
# check if 'outputs' dir exists and empty it if necessary
|
84 |
check_outputs_folder('./outputs')
|
85 |
|
|
|
134 |
command = ['python', 'inference.py', '--inference_config', file_path]
|
135 |
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
|
136 |
|
137 |
+
# Create a tqdm progress bar
|
138 |
+
progress_bar = tqdm(total=100, desc="Inference Progress", unit="line", ncols=100)
|
139 |
+
|
140 |
# Create threads to handle stdout and stderr
|
141 |
+
stdout_thread = threading.Thread(target=stream_output, args=(process.stdout, progress_bar))
|
142 |
+
stderr_thread = threading.Thread(target=stream_output, args=(process.stderr, progress_bar))
|
143 |
+
|
144 |
|
145 |
# Start the threads
|
146 |
stdout_thread.start()
|
|
|
150 |
process.wait()
|
151 |
stdout_thread.join()
|
152 |
stderr_thread.join()
|
153 |
+
|
154 |
+
# Close the progress bar
|
155 |
+
progress_bar.close()
|
156 |
|
157 |
print("Inference script finished with return code:", process.returncode)
|
158 |
|