File size: 924 Bytes
84f7796
1f661f5
574faf8
84f7796
 
1f661f5
f3cbe4a
84f7796
 
 
6d5137f
84f7796
9385aa0
45c0cf0
84f7796
d57a862
84f7796
 
d57a862
3868ab8
84f7796
d57a862
84f7796
 
f3cbe4a
 
 
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
import gradio as gr
import matplotlib.pyplot as plt
import tensorflow as tf

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, label = "Number of Examples to Generate")
image = gr.outputs.Image(type = "plot")

model = from_pretrained_keras("merve/anime-faces-generator")
def generate_and_save_images(number_of_examples):
  
  seed = tf.random.normal([number_of_examples, 100])
  predictions = model(seed, training=False)

  fig = plt.figure(figsize=(80, 80))

  for i in range(predictions.shape[0]):
      plt.subplot(2, 2, i+1)
      plt.imshow(predictions[i, :, :, :])
      plt.axis('off')
  return fig


description = "Anime face generator made with DCGAN"
gr.Interface(generate_and_save_images, inputs = [number_of_examples], outputs = image, 
title = "Anime Face Generator", description = description).launch()