XTEP63 commited on
Commit
84ce1d0
verified
1 Parent(s): 533459c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ # Cargar el modelo DAE desde Hugging Face
8
+ modelo_path = hf_hub_download(repo_id="XTEP63/VAE", filename="VAE.keras")
9
+ vae_model = tf.keras.models.load_model(modelo_path)
10
+
11
+ # Funci贸n para generar una imagen con el VAE
12
+ def generate_image():
13
+ latent_dim = 128
14
+ z_sample = np.random.normal(size=(1, latent_dim)) # Muestra aleatoria del espacio latente
15
+ output = vae_model.predict(z_sample) # Generar imagen
16
+ output = np.squeeze(output, axis=0)
17
+ output = (output * 255).astype(np.uint8)
18
+ return Image.fromarray(output)
19
+
20
+ # Interfaz con Gradio
21
+ iface_vae = gr.Interface(
22
+ fn=generate_image,
23
+ inputs=None,
24
+ outputs=gr.Image(type="pil"),
25
+ title="Variational Autoencoder",
26
+ description="Genera una imagen nueva basada en el espacio latente del VAE."
27
+ )
28
+
29
+ iface_vae.launch()