Spaces:
Sleeping
Sleeping
import gradio as gr | |
import numpy as np | |
from PIL import Image | |
def set_computer_params(computer): | |
# Esta funci贸n se mantiene igual que en el c贸digo original | |
# ... (c贸digo de set_computer_params) | |
def convert_to_pixelated_8bit(image, computer): | |
# Esta funci贸n se mantiene igual que en el c贸digo original | |
# ... (c贸digo de convert_to_pixelated_8bit) | |
def process_image(image, computer): | |
if image is None: | |
return None | |
return convert_to_pixelated_8bit(Image.fromarray(image), computer) | |
# Crear la interfaz gr谩fica de Gradio | |
with gr.Blocks() as iface: | |
gr.Markdown("# Emulador de Gr谩ficos de Computadoras Retro") | |
gr.Markdown("Sube una imagen, usa la c谩mara o emula el estilo gr谩fico de computadoras de los a帽os 80 con 8 bits y pixelado. Elige entre varias computadoras retro.") | |
with gr.Row(): | |
with gr.Column(): | |
input_image = gr.Image(source="upload", type="numpy", label="Subir Imagen") | |
camera_input = gr.Image(source="webcam", type="numpy", label="Usar C谩mara") | |
capture_button = gr.Button("Capturar Imagen") | |
computer_dropdown = gr.Dropdown( | |
["Commodore 64", "ZX Spectrum", "Amstrad CPC", "Atari 8-bit (400/800)", "Apple II", "MSX", "NES (Nintendo)", "IBM PC CGA"], | |
label="Elige una computadora retro", | |
value="Commodore 64" | |
) | |
output_image = gr.Image(type="numpy", label="Imagen convertida") | |
convert_button = gr.Button("Convertir Imagen") | |
# Conexiones | |
convert_button.click( | |
process_image, | |
inputs=[input_image, computer_dropdown], | |
outputs=output_image | |
) | |
capture_button.click( | |
lambda x: x, | |
inputs=camera_input, | |
outputs=input_image | |
) | |
gr.Markdown("Hecho con 鉂わ笍 en MDQ por Pel谩ez") | |
iface.launch() |