Spaces:
Sleeping
Sleeping
vukadinovic936
commited on
Commit
•
92a78e5
1
Parent(s):
1b8c586
switched to imageio
Browse files- Dockerfile +0 -1
- app.py +6 -6
- requirements.txt +1 -0
Dockerfile
CHANGED
@@ -16,7 +16,6 @@ RUN apt-get update -o Acquire::AllowInsecureRepositories=true \
|
|
16 |
RUN pip install --upgrade pip \
|
17 |
&& pip install --upgrade pip setuptools wheel \
|
18 |
&& pip install --no-cache-dir -r requirements.txt \
|
19 |
-
&& pip install opencv-python --verbose \
|
20 |
&& pip install jupyter
|
21 |
|
22 |
WORKDIR /data
|
|
|
16 |
RUN pip install --upgrade pip \
|
17 |
&& pip install --upgrade pip setuptools wheel \
|
18 |
&& pip install --no-cache-dir -r requirements.txt \
|
|
|
19 |
&& pip install jupyter
|
20 |
|
21 |
WORKDIR /data
|
app.py
CHANGED
@@ -5,7 +5,7 @@ import numpy as np
|
|
5 |
from pathlib import Path
|
6 |
import dnnlib
|
7 |
from dnnlib import tflib
|
8 |
-
import
|
9 |
import os
|
10 |
import subprocess
|
11 |
|
@@ -69,14 +69,14 @@ random_img_latent_code = Gs.components.mapping.run(z,None)
|
|
69 |
random_img_latent_code -= 0.7*latent_controls['time']
|
70 |
vid = frame_to_frame(random_img_latent_code)
|
71 |
|
72 |
-
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Codec for .mp4
|
73 |
-
temp_video_path="output.mp4"
|
74 |
-
out = cv2.VideoWriter(temp_video_path, fourcc, 20.0, (256, 256), isColor=False)
|
75 |
|
|
|
|
|
76 |
for i in range(vid.shape[0]):
|
77 |
frame = vid[i]
|
78 |
-
|
79 |
-
|
|
|
80 |
out_path = "fixed_out.mp4"
|
81 |
command = ["ffmpeg", "-i", temp_video_path, "-vcodec", "libx264", out_path]
|
82 |
subprocess.run(command)
|
|
|
5 |
from pathlib import Path
|
6 |
import dnnlib
|
7 |
from dnnlib import tflib
|
8 |
+
import imageio
|
9 |
import os
|
10 |
import subprocess
|
11 |
|
|
|
69 |
random_img_latent_code -= 0.7*latent_controls['time']
|
70 |
vid = frame_to_frame(random_img_latent_code)
|
71 |
|
|
|
|
|
|
|
72 |
|
73 |
+
temp_video_path="output.mp4"
|
74 |
+
writer=imageio.get_writer(temp_video_path, fps=20)
|
75 |
for i in range(vid.shape[0]):
|
76 |
frame = vid[i]
|
77 |
+
writer.append_data(frame)
|
78 |
+
|
79 |
+
writer.close()
|
80 |
out_path = "fixed_out.mp4"
|
81 |
command = ["ffmpeg", "-i", temp_video_path, "-vcodec", "libx264", out_path]
|
82 |
subprocess.run(command)
|
requirements.txt
CHANGED
@@ -5,3 +5,4 @@ ipywidgets
|
|
5 |
streamlit
|
6 |
numpy
|
7 |
pathlib
|
|
|
|
5 |
streamlit
|
6 |
numpy
|
7 |
pathlib
|
8 |
+
imagio
|