|
import gradio as gr |
|
from skimage import io |
|
from pyxelate import Pyx, Pal |
|
|
|
def pixel(image): |
|
image = io.imread(image.name) |
|
downsample_by = 14 |
|
palette = 7 |
|
|
|
pyx = Pyx(factor=downsample_by, palette=palette,depth=2,upscale = 14) |
|
|
|
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 8-bit 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")], |
|
gr.outputs.Image(type="file", label="Output"), |
|
title=title, |
|
description=description, |
|
article=article, |
|
enable_queue=True, |
|
examples=[['mona.jpeg']] |
|
).launch(debug=True) |