Background removal API
2025 · POSIMYTH
Upload a JPG or PNG and get back a transparent PNG at the original DPI. The image runs through U²-Net, a model built to separate the subject from its background.
how it works
My first version saved files to disk and returned their paths, which left files on the server. I rewrote it to process everything in memory and stream the PNG straight back, so nothing is stored. The model (about 170 MB) is baked into the Docker image at build time, so the API is ready from the first request.
what I learned
With ML models, startup time matters as much as inference.
Python · FastAPI · rembg · U²-Net · ONNX Runtime · Pillow · Docker