-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (26 loc) · 1.06 KB
/
app.py
File metadata and controls
29 lines (26 loc) · 1.06 KB
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
import os
import gradio as gr
from image_blurring import BlurImage
if __name__ == "__main__":
blur_image = BlurImage(device=None)
gr_interface = gr.Interface(
fn=lambda image, prompt, intensity, save=False: blur_image.blur(image, prompt.split("\n"), intensity, save=save),
inputs=[gr.Image(type="pil", label="Image"),
gr.Textbox(lines=3, placeholder="jacket\ndog head\netc...", label="Prompt"),
gr.Slider(minimum=0, maximum=400, step=10, value=50, label="Blur intensity")],
outputs=gr.Image(type="pil", label="Output"),
title="Blur Objects by Prompts",
examples=[
[os.path.join(os.path.dirname(__file__),
"images-to-blur",
"dogs.jpg"),
"jacket",
50],
[os.path.join(os.path.dirname(__file__),
"images-to-blur",
"hat_sunglasses.jpg"),
"hat\nsunglasses",
150]
]
)
gr_interface.launch()