Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import numpy as np
|
4 |
-
from PIL import Image
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
# ---
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
return img_array
|
16 |
-
|
17 |
-
def denoise_image(img):
|
18 |
-
""" Pasa la imagen ruidosa por el autoencoder y devuelve la imagen reconstruida. """
|
19 |
-
img_array = preprocess_image(img)
|
20 |
-
|
21 |
-
# Pasar la imagen por el autoencoder
|
22 |
-
denoised_img = model.predict(img_array)
|
23 |
-
|
24 |
-
# Postprocesamiento
|
25 |
-
denoised_img = np.squeeze(denoised_img) # Remover batch dimension
|
26 |
-
denoised_img = (denoised_img * 255).astype(np.uint8) # Convertir a formato uint8
|
27 |
-
return denoised_img
|
28 |
-
|
29 |
-
# --- Interfaz Gradio ---
|
30 |
-
gr.Interface(fn=denoise_image,
|
31 |
-
inputs=gr.Image(type="pil"), # Imagen de entrada
|
32 |
-
outputs=gr.Image(type="numpy"), # Imagen de salida
|
33 |
-
examples=["noisy1.jpg", "noisy2.jpg"] # Ejemplos opcionales
|
34 |
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from preprocess import preprocess_single_image # Importamos la funci贸n de preprocesamiento
|
|
|
|
|
3 |
|
4 |
+
def process_image(img):
|
5 |
+
"""
|
6 |
+
Recibe una imagen del usuario y la devuelve en dos versiones:
|
7 |
+
- Imagen normalizada
|
8 |
+
- Imagen con ruido agregado
|
9 |
+
"""
|
10 |
+
img_clean, img_noisy = preprocess_single_image(img)
|
11 |
+
return img_clean, img_noisy # Devuelve ambas im谩genes
|
12 |
|
13 |
+
# --- Interfaz de Gradio ---
|
14 |
+
gr.Interface(fn=process_image,
|
15 |
+
inputs=gr.Image(type="pil"),
|
16 |
+
outputs=[gr.Image(type="numpy", label="Imagen Normalizada"),
|
17 |
+
gr.Image(type="numpy", label="Imagen con Ruido")],
|
18 |
+
examples=["example1.jpg", "example2.jpg"] # Opcional
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
).launch()
|