File size: 997 Bytes
83e45f7
f8a7901
 
 
83e45f7
 
ed4fbc0
f8a7901
 
 
183a745
f8a7901
 
 
 
183a745
047136e
 
f8a7901
 
 
 
ed4fbc0
f8a7901
1cee841
183a745
 
f8a7901
 
047136e
183a745
f8a7901
 
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
import gradio as gr
import tensorflow as tf
import matplotlib.pyplot as plt
from huggingface_hub import from_pretrained_keras


n_images = 36
codings_size = 100
hub_generator = from_pretrained_keras("huggan/crypto-gan")


def post_process(image):
    image = ((image + 1) / 2) # scale back
    return image


def generate(seed):
    noise = tf.random.normal(shape=[n_images, codings_size], seed=seed)
    generated_images = hub_generator(noise, training=False)

    fig = plt.figure(figsize=(10, 10))
    for i in range(generated_images.shape[0]):
        plt.subplot(6, 6, i+1)
        plt.imshow(post_process(generated_images[i, :, :, :]), cmap="binary")
        plt.axis("off")
    return fig


gr.Interface(fn=generate, 
            inputs=[gr.inputs.Slider(label='Seed', minimum=0, maximum=1000, default=42)], 
            outputs=gr.outputs.Image(type="plot"), 
            title="CryptoGAN", 
            description="These CryptoPunks do not exist. gGnerate your own CryptoPunks").launch()