diff --git a/src/rmbg_as_a_service/server.py b/src/rmbg_as_a_service/server.py index 15945d6..c4d6fa0 100644 --- a/src/rmbg_as_a_service/server.py +++ b/src/rmbg_as_a_service/server.py @@ -41,13 +41,15 @@ from pathlib import Path import litserve as ls from fastapi import HTTPException -from fastapi.responses import HTMLResponse +from fastapi.responses import HTMLResponse, Response from PIL import Image, ImageOps from .model import BiRefNetService from .prompt_segment import PromptSegmenter -_UI_HTML = (Path(__file__).parent / "static" / "index.html").read_text(encoding="utf-8") +_STATIC = Path(__file__).parent / "static" +_UI_HTML = (_STATIC / "index.html").read_text(encoding="utf-8") +_UI_CSS = (_STATIC / "styles.css").read_text(encoding="utf-8") # Lazily-created prompt segmenter (DINO + SAM), shared by the /segment route. _segmenter: PromptSegmenter | None = None @@ -132,6 +134,10 @@ def run() -> None: def index() -> str: return _UI_HTML + @server.app.get("/styles.css") + def styles() -> Response: + return Response(_UI_CSS, media_type="text/css") + @server.app.post("/segment") def segment(payload: dict) -> dict: """Prompt-conditioned segmentation (GroundingDINO + SAM).""" diff --git a/src/rmbg_as_a_service/static/index.html b/src/rmbg_as_a_service/static/index.html index eec01c9..7819c9c 100644 --- a/src/rmbg_as_a_service/static/index.html +++ b/src/rmbg_as_a_service/static/index.html @@ -3,312 +3,350 @@
-Drop an image here or click to choose
-No file selected
- -