-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (24 loc) · 1004 Bytes
/
app.py
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
import os
import os.path as osp
import cv2
from utils import normalize
import streamlit as st
import tensorflow as tf
from utils import load_env
from models.nn.generator import DCGANGenerator
load_env()
def generate_random_input():
return tf.random.normal((1, 100))
if __name__ == '__main__':
st.title('Generator Evaluation')
saved_generator = os.listdir(os.environ['ASSETS'])
selected_generator = st.selectbox('Select the Generator model', saved_generator)
if selected_generator is not None:
full_path_generator = osp.join(os.environ['ASSETS'], selected_generator, 'saved_model.hdf5')
generator = DCGANGenerator(None, None, from_path=full_path_generator)
button_clicked = st.button('Generate input')
if button_clicked:
random_input = generate_random_input()
out_image = generator.predict(random_input, training=False)
img = cv2.resize(normalize(out_image[0].numpy()), (250, 250))
st.image(img)