Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -53,11 +53,10 @@ def optimize_image(image, png_optimize, jpeg_quality, jpeg_resolution, webp_qual
|
|
53 |
webp_lossy_img, f"WebP con pérdida: {webp_lossy_size:.2f} KB \n(diferencia: {-webp_lossy_diff:.2f} KB)", webp_lossy_output_path
|
54 |
]
|
55 |
|
56 |
-
# Función
|
57 |
-
def
|
58 |
-
|
59 |
-
|
60 |
-
return super_res_img
|
61 |
|
62 |
with gr.Blocks() as demo:
|
63 |
with gr.Tab("Optimización Tradicional"):
|
@@ -103,13 +102,18 @@ with gr.Blocks() as demo:
|
|
103 |
|
104 |
with gr.Tab("Optimización con Modelos de Hugging Face"):
|
105 |
hf_image_input = gr.File(label="Sube tu imagen para optimización avanzada", file_types=['image'])
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
hf_button.click(
|
110 |
-
fn=
|
111 |
-
inputs=hf_image_input,
|
112 |
-
outputs=
|
113 |
)
|
114 |
|
115 |
demo.launch()
|
|
|
53 |
webp_lossy_img, f"WebP con pérdida: {webp_lossy_size:.2f} KB \n(diferencia: {-webp_lossy_diff:.2f} KB)", webp_lossy_output_path
|
54 |
]
|
55 |
|
56 |
+
# Función para aplicar un modelo seleccionado desde Hugging Face
|
57 |
+
def apply_model(image, model_name):
|
58 |
+
model_pipeline = pipeline("image-super-resolution", model=model_name)
|
59 |
+
return model_pipeline(image)
|
|
|
60 |
|
61 |
with gr.Blocks() as demo:
|
62 |
with gr.Tab("Optimización Tradicional"):
|
|
|
102 |
|
103 |
with gr.Tab("Optimización con Modelos de Hugging Face"):
|
104 |
hf_image_input = gr.File(label="Sube tu imagen para optimización avanzada", file_types=['image'])
|
105 |
+
model_selector = gr.Dropdown(
|
106 |
+
label="Selecciona un modelo",
|
107 |
+
choices=["xinntao/Real-ESRGAN", "google/ddpm-cifar10-32", "facebook/ddpm"], # Añade los modelos disponibles
|
108 |
+
value="xinntao/Real-ESRGAN"
|
109 |
+
)
|
110 |
+
hf_output = gr.Image(label="Resultado")
|
111 |
+
hf_button = gr.Button("Aplicar Modelo")
|
112 |
|
113 |
hf_button.click(
|
114 |
+
fn=apply_model,
|
115 |
+
inputs=[hf_image_input, model_selector],
|
116 |
+
outputs=hf_output
|
117 |
)
|
118 |
|
119 |
demo.launch()
|