Create app.py
Browse files
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()
|