merve's picture
merve HF staff
Update app.py
45c0cf0
raw
history blame
769 Bytes
import gradio as gr
import matplotlib.pyplot as plt
from huggingface_hub import from_pretrained_keras
seed = gr.inputs.Slider(step = 1)
number_of_examples = gr.inputs.Slider(minimum = 1, maximum = 4, step = 1)
image = gr.outputs.Image(type = "plot")
model = from_pretrained_keras("merve/anime-faces-generator")
def generate_and_save_images(seed, number_of_examples):
seed = tf.random.normal([number_of_examples, seed])
predictions = model(seed, training=False)
fig = plt.figure(figsize=(16, 64))
for i in range(predictions.shape[0]):
plt.subplot(1, 4, i+1)
plt.imshow(predictions[i, :, :, :])
plt.axis('off')
return plt
gr.Interface(generate_and_save_images, inputs = [seed, number_of_examples], outputs = image).launch(debug=True)