|
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) |
|
palette = int(palette) |
|
|
|
pyx = Pyx(factor=downsample_by, palette=palette,depth=int(depth),upscale = int(upscale)) |
|
|
|
pyx.fit(image) |
|
|
|
new_image = pyx.transform(image) |
|
|
|
io.imsave("pixel.png", new_image) |
|
return "pixel.png" |
|
|
|
title = "Pyxelate" |
|
description = "Gradio demo for Pyxelate: converts images to pixel art. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below." |
|
article = "<p style='text-align: center'><a href='https://github.com/sedthh/pyxelate' target='_blank'>Github Repo</a></p>" |
|
|
|
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]] |
|
).launch(enable_queue=True) |