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()
|