Spaces:
Running
on
Zero
Running
on
Zero
Update stf_utils.py
Browse files- stf_utils.py +32 -18
stf_utils.py
CHANGED
@@ -2,7 +2,7 @@ import torch
|
|
2 |
import os
|
3 |
from concurrent.futures import ThreadPoolExecutor
|
4 |
from pydub import AudioSegment
|
5 |
-
import cv2
|
6 |
from pathlib import Path
|
7 |
import subprocess
|
8 |
from pathlib import Path
|
@@ -133,24 +133,38 @@ class STFPipeline:
|
|
133 |
pivot = 0
|
134 |
results = []
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
|
138 |
-
with ThreadPoolExecutor(4) as p:
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
print('STFPipeline execute 3')
|
156 |
images2video(results, save_path)
|
|
|
2 |
import os
|
3 |
from concurrent.futures import ThreadPoolExecutor
|
4 |
from pydub import AudioSegment
|
5 |
+
import cv2, cv2.setNumThreads(0); cv2.ocl.setUseOpenCL(False)
|
6 |
from pathlib import Path
|
7 |
import subprocess
|
8 |
from pathlib import Path
|
|
|
133 |
pivot = 0
|
134 |
results = []
|
135 |
|
136 |
+
try:
|
137 |
+
|
138 |
+
gen_infer = self.template.gen_infer(
|
139 |
+
audio_segment,
|
140 |
+
pivot,
|
141 |
+
)
|
142 |
+
for idx, (it, chunk) in enumerate(gen_infer, pivot):
|
143 |
+
frame = next(reader)
|
144 |
+
composed = self.template.compose(idx, frame, it)
|
145 |
+
frame_name = f"{idx}".zfill(5)+".jpg"
|
146 |
+
results.append(it['pred'])
|
147 |
+
pivot = idx + 1
|
148 |
+
except StopIteration as e:
|
149 |
+
pass
|
150 |
|
151 |
+
|
152 |
+
# with ThreadPoolExecutor(4) as p:
|
153 |
+
# try:
|
154 |
+
|
155 |
+
# gen_infer = self.template.gen_infer_concurrent(
|
156 |
+
# p,
|
157 |
+
# audio_segment,
|
158 |
+
# pivot,
|
159 |
+
# )
|
160 |
+
# for idx, (it, chunk) in enumerate(gen_infer, pivot):
|
161 |
+
# frame = next(reader)
|
162 |
+
# composed = self.template.compose(idx, frame, it)
|
163 |
+
# frame_name = f"{idx}".zfill(5)+".jpg"
|
164 |
+
# results.append(it['pred'])
|
165 |
+
# pivot = idx + 1
|
166 |
+
# except StopIteration as e:
|
167 |
+
# pass
|
168 |
|
169 |
print('STFPipeline execute 3')
|
170 |
images2video(results, save_path)
|