Spaces:
Runtime error
Runtime error
video forward to back
Browse files
app.py
CHANGED
@@ -269,11 +269,24 @@ def encode_img_fn(img, noise):
|
|
269 |
return "success", imgs[0], img_out, w, get_thumbnail(img_out)
|
270 |
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
def gen_video_fn(w1, w2, noise, frame):
|
273 |
if w1 is None or w2 is None:
|
274 |
return None
|
275 |
-
model.gen_video(w1, w2, noise, "video.mp4", int(frame))
|
276 |
-
|
|
|
277 |
|
278 |
|
279 |
if __name__ == '__main__':
|
|
|
269 |
return "success", imgs[0], img_out, w, get_thumbnail(img_out)
|
270 |
|
271 |
|
272 |
+
def gen_video2(self, w1, w2, noise, path, frame_num=10):
|
273 |
+
video = imageio.get_writer(path, mode='I', fps=frame_num // 2, codec='libx264', bitrate='16M')
|
274 |
+
lin = np.linspace(0, 1, frame_num)
|
275 |
+
for i in range(0, frame_num):
|
276 |
+
img = self.get_img(((1 - lin[i]) * w1) + (lin[i] * w2), noise)
|
277 |
+
video.append_data(img)
|
278 |
+
for i in range(frame_num, 0, -1):
|
279 |
+
img = self.get_img(((1 - lin[i]) * w1) + (lin[i] * w2), noise)
|
280 |
+
video.append_data(img)
|
281 |
+
video.close()
|
282 |
+
|
283 |
+
|
284 |
def gen_video_fn(w1, w2, noise, frame):
|
285 |
if w1 is None or w2 is None:
|
286 |
return None
|
287 |
+
# model.gen_video(w1, w2, noise, "video.mp4", int(frame))
|
288 |
+
model.gen_video2(w1, w2, noise, "video.mp4", int(frame))
|
289 |
+
return "videoFB.mp4"
|
290 |
|
291 |
|
292 |
if __name__ == '__main__':
|