Spaces:
Sleeping
Sleeping
File size: 1,367 Bytes
626ed5d 9f786f6 36e5189 9f786f6 fd8e8f6 9f786f6 | 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 34 35 36 37 38 39 40 | import gradio as gr
# Importar las librer铆as necesarias
from PIL import Image, ImageEnhance
import numpy as np
# Funci贸n que procesa la informaci贸n de los componentes de entrada y devuelve los resultados para mostrar en el componente de salida.
def editar_imagen(image, rotacion, brillo):
# Convertir a PIL Image si es un numpy array
if isinstance(image, np.ndarray):
image = Image.fromarray(image)
# Rotar la imagen
imagen_rotada = image.rotate(rotacion)
# Ajustar el brillo
enhancer = ImageEnhance.Brightness(imagen_rotada)
imagen_brillo = enhancer.enhance(brillo)
return imagen_brillo
# Definir la interfaz de Gradio
iface = gr.Interface(
fn=editar_imagen,
inputs=[
gr.Image(type="pil", label="Imagen Original"),
gr.Slider(minimum=-180, maximum=180, step=1, value=0, label="Rotaci贸n (grados)"),
gr.Slider(minimum=0.1, maximum=3.0, step=0.1, value=1.0, label="Brillo"),
],
outputs=gr.Image(type="pil", label="Imagen Editada"),
title="Editor de Im谩genes B谩sico",
description="Sube una imagen y ajusta la rotaci贸n y el brillo.",
examples=[
["https://drive.usercontent.google.com/uc?id=1mZ1ArH5udznD-yScE7wyJptb67o5hqiO", 45, 1.5],
["https://drive.usercontent.google.com/uc?id=1gwJ_BhPejkp4UYh7khKQ4p9YQL32cc-K", 45, 1.5],
]
)
# Lanzar la interfaz
iface.launch() |