--- title: BRIA RMBG 1.4 emoji: 💻 colorFrom: red colorTo: red sdk: docker pinned: false license: other --- BRIA RMBG 1.4 - Dockerized Web App and API This is a Docker-based FastAPI service with a simple HTML frontend and a programmatic API for background removal. Features - FastAPI backend serving: - POST /api/remove_bg (returns PNG bytes or JSON base64) - POST /api/matte (alpha matte) - GET /health - Static HTML/CSS/JS UI under /static - Dockerfile for containerized deployment Local development - Install deps (recommended inside a venv): pip install -r requirements.txt fastapi uvicorn[standard] - Run uvicorn server:app --host 0.0.0.0 --port 7860 - Open http://localhost:7860 Docker - Build docker build -t bria-rmbg:latest . - Run docker run --rm -p 7860:7860 bria-rmbg:latest API examples - cURL (PNG bytes) curl -X POST "http://localhost:7860/api/remove_bg?output=image" -F "file=@./input.jpg" --output result.png - cURL (JSON base64) curl -X POST "http://localhost:7860/api/remove_bg?output=json" -F "file=@./input.jpg" | jq -r .image_base64 | base64 --decode > result.png - Python import requests with open("./input.jpg", "rb") as f: r = requests.post( "http://localhost:7860/api/remove_bg?output=image", files={"file": ("image.jpg", f, "image/jpeg")}, ) open("result.png", "wb").write(r.content) Notes - On first run the model weights (briaai/RMBG-1.4) are downloaded from Hugging Face Hub. - For GPU support, use a CUDA-enabled base image and ensure PyTorch CUDA is installed.