Spaces:
Sleeping
Sleeping
Update stf_utils.py
Browse files- stf_utils.py +35 -16
stf_utils.py
CHANGED
@@ -130,22 +130,41 @@ class STFPipeline:
|
|
130 |
audio_segment = AudioSegment.from_file(audio)
|
131 |
pivot = 0
|
132 |
results = []
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
print('STFPipeline execute 3')
|
151 |
images2video(results, save_path)
|
|
|
130 |
audio_segment = AudioSegment.from_file(audio)
|
131 |
pivot = 0
|
132 |
results = []
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
try:
|
137 |
+
# 순차적으로 gen_infer를 실행
|
138 |
+
gen_infer = self.template.gen_infer(audio_segment, pivot)
|
139 |
+
|
140 |
+
for idx, (it, chunk) in enumerate(gen_infer, pivot):
|
141 |
+
frame = next(reader) # 다음 프레임을 읽음
|
142 |
+
composed = self.template.compose(idx, frame, it) # 합성 작업 수행
|
143 |
+
frame_name = f"{idx}".zfill(5) + ".jpg"
|
144 |
+
results.append(it['pred']) # 결과를 저장
|
145 |
+
pivot = idx + 1
|
146 |
+
|
147 |
+
except StopIteration as e:
|
148 |
+
pass
|
149 |
+
|
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)
|