Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,31 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
from matplotlib import cm
|
5 |
+
from PIL import Image
|
6 |
+
import imageio
|
7 |
|
8 |
+
generator = tf.keras.models.load_model('dc_gan.h5')
|
|
|
9 |
|
10 |
+
def interpolate(start,end,steps,fps):
|
11 |
+
|
12 |
+
input_vectors = np.squeeze(np.linspace(start,end,steps))
|
13 |
+
|
14 |
+
image_vectors = np.array(generator(input_vectors))
|
15 |
+
|
16 |
+
writer = imageio.get_writer('test.mp4', fps=fps)
|
17 |
+
|
18 |
+
for im in image_vectors:
|
19 |
+
writer.append_data((im*255).astype('uint8'))
|
20 |
+
writer.close()
|
21 |
+
|
22 |
+
return gr.Video(value = 'test.mp4')
|
23 |
+
|
24 |
+
output_interpolation = gr.Video()
|
25 |
+
demo = gr.Blocks()
|
26 |
+
|
27 |
+
with demo:
|
28 |
+
btn = gr.Button("Submit")
|
29 |
+
btn.click(interpolate, inputs=[start,end,steps,fps], outputs=[output_interpolation])
|
30 |
+
|
31 |
+
demo.launch()
|