tomaseo2022 commited on
Commit
a97d770
1 Parent(s): 53ed86e

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +32 -0
  2. gitattributes.txt +27 -0
  3. mona.jpeg +0 -0
  4. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from skimage import io
3
+ from pyxelate import Pyx, Pal
4
+
5
+ def pixel(image,downsample,palette,depth,upscale):
6
+ image = io.imread(image.name)
7
+ downsample_by = int(downsample) # new image will be 1/14th of the original in size
8
+ palette = int(palette) # find 7 colors
9
+ # 1) Instantiate Pyx transformer
10
+ pyx = Pyx(factor=downsample_by, palette=palette,depth=int(depth),upscale = int(upscale))
11
+ # 2) fit an image, allow Pyxelate to learn the color palette
12
+ pyx.fit(image)
13
+ # 3) transform image to pixel art using the learned color palette
14
+ new_image = pyx.transform(image)
15
+ # save new image with 'skimage.io.imsave()'
16
+ io.imsave("pixel.png", new_image)
17
+ return "pixel.png"
18
+
19
+ title = "Pyxelate"
20
+ 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."
21
+ article = "<p style='text-align: center'><a href='https://github.com/sedthh/pyxelate' target='_blank'>Github Repo</a></p>"
22
+
23
+ gr.Interface(
24
+ pixel,
25
+ [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")
26
+ ],
27
+ gr.outputs.Image(type="file", label="Output"),
28
+ title=title,
29
+ description=description,
30
+ article=article,
31
+ examples=[['mona.jpeg',14,7,1,14]]
32
+ ).launch(enable_queue=True)
gitattributes.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
mona.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ scikit-learn>=0.24.1
2
+ scikit-image>=0.18.1
3
+ numba>=0.53.1
4
+ git+https://github.com/sedthh/pyxelate.git