sungdo1 commited on
Commit
cd881be
โ€ข
1 Parent(s): 7a88688

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from rembg import remove
3
+
4
+ # ๋ฐฐ๊ฒฝ์„ ์ œ๊ฑฐํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
5
+ def remove_background(image):
6
+ output_image = remove(image)
7
+ return output_image
8
+
9
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
10
+ with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ # ์‚ฌ์šฉ์ž๊ฐ€ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
13
+ image_input = gr.Image(type="pil", tool="editor")
14
+ # ๋ฐฐ๊ฒฝ์ด ์ œ๊ฑฐ๋œ ์ด๋ฏธ์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
15
+ image_output = gr.Image(type="pil")
16
+
17
+ # ์‚ฌ์šฉ์ž๊ฐ€ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๋ฉด `remove_background` ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜์–ด ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.
18
+ image_input.change(fn=remove_background, inputs=image_input, outputs=image_output)
19
+
20
+ # ์•ฑ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
21
+ if __name__ == "__main__":
22
+ demo.launch()