Spaces:
Running
Running
ziqiangao
commited on
Commit
·
717e2ff
1
Parent(s):
7835f68
better debug progress
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ import tempfile
|
|
13 |
import ffmpeg
|
14 |
import subprocess
|
15 |
import traceback
|
16 |
-
import time
|
17 |
import shutil
|
18 |
import LRC2SRT
|
|
|
19 |
|
20 |
flag = 1
|
21 |
|
@@ -167,6 +167,23 @@ def stripinvisibles(s):
|
|
167 |
e.replace(i,"")
|
168 |
return e
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
haslyrics = False
|
171 |
|
172 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None, img=None, tit=None, ast=None):
|
@@ -253,7 +270,7 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
253 |
print('Frame Count: ' + str(num_frames))
|
254 |
print('Segments per frame: ' + str(oscres))
|
255 |
print('---------------------------------------------------------')
|
256 |
-
|
257 |
try:
|
258 |
with Pool(cpu_count()) as pool:
|
259 |
num_frames = len(samples_array) // (sr // fps)
|
@@ -261,10 +278,12 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics
|
|
261 |
for _ in pool.imap_unordered(render_frame, params):
|
262 |
iii += 1 # Increment frame count for progress
|
263 |
p((iii, num_frames), desc="Rendering Frames")
|
264 |
-
|
265 |
|
266 |
except Exception as e:
|
267 |
raise gr.Error("Something went wrong whilst rendering")
|
|
|
|
|
268 |
|
269 |
p = gr.Progress()
|
270 |
p(0.5, desc="Compiling video")
|
|
|
13 |
import ffmpeg
|
14 |
import subprocess
|
15 |
import traceback
|
|
|
16 |
import shutil
|
17 |
import LRC2SRT
|
18 |
+
import sys
|
19 |
|
20 |
flag = 1
|
21 |
|
|
|
167 |
e.replace(i,"")
|
168 |
return e
|
169 |
|
170 |
+
def start_progress(title):
|
171 |
+
global progress_x
|
172 |
+
sys.stdout.write(title + ": [" + "-"*40 + "]" + chr(8)*41)
|
173 |
+
sys.stdout.flush()
|
174 |
+
progress_x = 0
|
175 |
+
|
176 |
+
def progress(x):
|
177 |
+
global progress_x
|
178 |
+
x = int(x * 40 // 100)
|
179 |
+
sys.stdout.write("#" * (x - progress_x))
|
180 |
+
sys.stdout.flush()
|
181 |
+
progress_x = x
|
182 |
+
|
183 |
+
def end_progress():
|
184 |
+
sys.stdout.write("#" * (40 - progress_x) + "]\n")
|
185 |
+
sys.stdout.flush()
|
186 |
+
|
187 |
haslyrics = False
|
188 |
|
189 |
def main(file, name, fps=30, res: tuple=(1280,720), oscres=512, sr=11025, lyrics=None, img=None, tit=None, ast=None):
|
|
|
270 |
print('Frame Count: ' + str(num_frames))
|
271 |
print('Segments per frame: ' + str(oscres))
|
272 |
print('---------------------------------------------------------')
|
273 |
+
start_progress("Rendering:")
|
274 |
try:
|
275 |
with Pool(cpu_count()) as pool:
|
276 |
num_frames = len(samples_array) // (sr // fps)
|
|
|
278 |
for _ in pool.imap_unordered(render_frame, params):
|
279 |
iii += 1 # Increment frame count for progress
|
280 |
p((iii, num_frames), desc="Rendering Frames")
|
281 |
+
progress((iii/num_frames)*100)
|
282 |
|
283 |
except Exception as e:
|
284 |
raise gr.Error("Something went wrong whilst rendering")
|
285 |
+
finally:
|
286 |
+
end_progress()
|
287 |
|
288 |
p = gr.Progress()
|
289 |
p(0.5, desc="Compiling video")
|