File size: 941 Bytes
9a4d90c
06ea643
 
 
 
 
9a4d90c
06ea643
9a4d90c
0ffbf81
 
 
 
 
 
06ea643
 
 
 
 
 
 
 
 
 
 
 
 
0ffbf81
6af468f
06ea643
6af468f
 
 
06ea643
0ffbf81
06ea643
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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(steps,fps):
    
    #CHANGE LATER
    start = tf.random.normal(shape=(1,128))
    end = tf.random.normal(shape=(1,128))
    #---------------
    
    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')


demo = gr.Blocks()
with demo:
    output_interpolation = gr.Video()
    STEPS = gr.Slider(1, 100, step=1)
    FPS = gr.Slider(1, 50, step=1)
    btn = gr.Button("Submit")
    btn.click(interpolate, inputs=[STEPS ,FPS], outputs=[output_interpolation])

demo.launch()