Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,10 @@ import gradio as gr
|
|
| 7 |
from briarmbg import BriaRMBG
|
| 8 |
from PIL import Image
|
| 9 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# 모델 로드
|
| 12 |
net = BriaRMBG()
|
|
@@ -55,20 +59,24 @@ def process(image):
|
|
| 55 |
|
| 56 |
return new_im, output_path
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
''
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
if __name__ == "__main__":
|
| 74 |
-
|
|
|
|
| 7 |
from briarmbg import BriaRMBG
|
| 8 |
from PIL import Image
|
| 9 |
import os
|
| 10 |
+
from fastapi import FastAPI
|
| 11 |
+
import uvicorn
|
| 12 |
+
|
| 13 |
+
app = FastAPI()
|
| 14 |
|
| 15 |
# 모델 로드
|
| 16 |
net = BriaRMBG()
|
|
|
|
| 59 |
|
| 60 |
return new_im, output_path
|
| 61 |
|
| 62 |
+
gradio_interface = gr.Interface(
|
| 63 |
+
fn=process,
|
| 64 |
+
inputs="image",
|
| 65 |
+
outputs=["image", "file"],
|
| 66 |
+
title="이미지 배경 제거",
|
| 67 |
+
description="이미지의 배경을 제거하고 결과 이미지를 다운로드할 수 있는 데모입니다.",
|
| 68 |
+
examples=[['./input.jpeg']]
|
| 69 |
+
)
|
| 70 |
|
| 71 |
+
@app.get("/")
|
| 72 |
+
def read_root():
|
| 73 |
+
return {"message": "BRIA RMBG API"}
|
| 74 |
|
| 75 |
+
@app.get("/gradio")
|
| 76 |
+
def gradio_api():
|
| 77 |
+
return gradio_interface.queue(max_size=12).launch(
|
| 78 |
+
server_name="0.0.0.0", server_port=7910, show_api=True
|
| 79 |
+
)
|
| 80 |
|
| 81 |
if __name__ == "__main__":
|
| 82 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|