File size: 1,294 Bytes
a97d770
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ad138f
8ce02d1
3e99869
 
4c257a6
2376fb4
a97d770
 
 
 
 
 
 
 
2b8759b
 
58c4d85
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
import gradio as gr
from skimage import io
from pyxelate import Pyx, Pal

def pixel(image,downsample,palette,depth,upscale):
    image = io.imread(image.name)  
    downsample_by = int(downsample)  # new image will be 1/14th of the original in size
    palette = int(palette)  # find 7 colors
    # 1) Instantiate Pyx transformer
    pyx = Pyx(factor=downsample_by, palette=palette,depth=int(depth),upscale = int(upscale))
    # 2) fit an image, allow Pyxelate to learn the color palette
    pyx.fit(image)
    # 3) transform image to pixel art using the learned color palette
    new_image = pyx.transform(image)
    # save new image with 'skimage.io.imsave()'
    io.imsave("pixel.png", new_image)
    return "pixel.png"
   
title = "Pixelar Imagen"
description = ""
article = ""


gr.Interface(
    pixel, 
    [gr.inputs.Image(type="file", label="Input", shape=(512,512)),gr.inputs.Number(default=14, label="downsample by"),gr.inputs.Number(default=7, label="palette"),gr.inputs.Number(default=1, label="depth"),gr.inputs.Number(default=14, label="upscale")
], 
    gr.outputs.Image(type="file", label="Output"),
    title=title,
    description=description,
    article=article,
    examples=[['mona.jpeg',14,7,1,14]],
    css="footer {visibility: hidden}"
    ).launch(enable_queue=True)