Spaces:
Runtime error
Runtime error
def create_digit_samples(num_images): | |
random_latent_vectors = tf.random.normal(shape=(int(num_images), 128)) | |
predictions = model.predict(random_latent_vectors) | |
num = ceil(sqrt(num_images)) | |
digit_images = np.zeros((28*num, 28*num), dtype=float) | |
n = 0 | |
for i in range(num): | |
for j in range(num): | |
if n == num_images: | |
break | |
digit_images[i* 28 : (i+1)*28, j*28 : (j+1)*28] = predictions[n, :, :, 0] | |
n += 1 | |
return digit_images | |
title = "WGAN-GP" | |
description = "Image Generation Using WGAN" | |
article = """ | |
<p style='text-align: center'> | |
<a href='https://keras.io/examples/generative/wgan_gp/' target='_blank'>Keras Example given by A_K_Nain</a> | |
<br> | |
Space by Gitesh Chawda | |
</p> | |
""" | |
inputs = gr.inputs.Number(label="number of images") | |
outputs = gr.outputs.Image(label="Predictions") | |
examples = [ | |
[4], | |
[7], | |
[8], | |
[2], | |
[10] | |
] | |
gr.Interface(create_digit_samples, inputs, outputs, title=title, examples=examples, description=description, article=article, analytics_enabled=False).launch(debug=True) |