DCGAN / app.py
egesko's picture
Update app.py
06ea643
raw
history blame
753 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from matplotlib import cm
from PIL import Image
import imageio
generator = tf.keras.models.load_model('dc_gan.h5')
def interpolate(start,end,steps,fps):
input_vectors = np.squeeze(np.linspace(start,end,steps))
image_vectors = np.array(generator(input_vectors))
writer = imageio.get_writer('test.mp4', fps=fps)
for im in image_vectors:
writer.append_data((im*255).astype('uint8'))
writer.close()
return gr.Video(value = 'test.mp4')
output_interpolation = gr.Video()
demo = gr.Blocks()
with demo:
btn = gr.Button("Submit")
btn.click(interpolate, inputs=[start,end,steps,fps], outputs=[output_interpolation])
demo.launch()