kuko6 commited on
Commit
5585d64
·
1 Parent(s): 4a7737f

added simple ui

Browse files
Files changed (3) hide show
  1. .gitignore +4 -0
  2. .vscode/settings.json +0 -3
  3. app.py +33 -0
.gitignore CHANGED
@@ -1,4 +1,8 @@
1
  .DS_Store
 
 
 
2
  imgs/
 
3
  *.jpg
4
  *.jpeg
 
1
  .DS_Store
2
+ .gradio/
3
+ .vscode/
4
+
5
  imgs/
6
+
7
  *.jpg
8
  *.jpeg
.vscode/settings.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "python.analysis.autoImportCompletions": false
3
- }
 
 
 
 
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+
4
+
5
+ def pixelate(img, pixel_size: int, blur=False):
6
+ if blur:
7
+ img = cv2.blur(img, (7, 7))
8
+
9
+ for i in range(0, img.shape[0], pixel_size):
10
+ for j in range(0, img.shape[1], pixel_size):
11
+ img[i : i + pixel_size, j : j + pixel_size] = img[i][j]
12
+
13
+ return img
14
+
15
+
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("# Simple Pixelart Filter")
18
+ with gr.Row():
19
+ with gr.Column(variant="panel"):
20
+ img = gr.Image(label="Input Image")
21
+ pixel_size = gr.Number(label="Pixel Size", minimum=1, value=16)
22
+ blur = gr.Checkbox(label="Blur")
23
+ with gr.Column():
24
+ output = gr.Image(
25
+ label="Output Image", format="jpeg", show_share_button=True
26
+ )
27
+
28
+ with gr.Column():
29
+ btn = gr.Button("Pixelate", variant="primary")
30
+ btn.click(fn=pixelate, inputs=[img, pixel_size, blur], outputs=output)
31
+ btn_clear = gr.ClearButton(components=[img, blur, output])
32
+
33
+ demo.launch(debug=True, pwa=True)