File size: 1,860 Bytes
2d40c9d
 
 
 
 
d3b70c7
 
2d40c9d
 
d3b70c7
 
 
 
2d40c9d
 
d3b70c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d40c9d
d3b70c7
2d40c9d
d3b70c7
2d40c9d
d3b70c7
 
 
 
 
 
2d40c9d
d3b70c7
 
 
 
 
2d40c9d
d3b70c7
2d40c9d
d3b70c7
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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()