chrisaldikaraharja's picture
Update app.py
6aba2ae verified
import streamlit as st
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
from PIL import Image
st.write("Loading model...")
module = hub.load("https://tfhub.dev/google/progan-128/1")
def generate_random_face():
latent_vector = np.random.normal(size=[1,512]).astype(np.float32)
image = module.signatures['default'](tf.constant(latent_vector))['default']
image = np.uint8(image.numpy()[0]*255)
return Image.fromarray(image)
st.title("Random Face Generator")
st.write("Click the button below to generate a random AI generated face")
if st.button("Generate Random Face"):
generated_image = generate_random_face()
st.image(generated_image, caption="Generated Face", use_container_width=True)
image_array = np.array(generated_image)
txt_filename = "generated_face.txt"
np.savetxt(txt_filename,image_array.flatten(), fmt="%d")
st.download_button("Download Image as TXT", txt_filename, txt_filename, "text/plain")
st.sidebar.write("App Version: 1.0")
st.sidebar.write("Model: ProGAN-128 from Tensorflow Hub")