Skip to content

Deployment

Mehrdad Pajuhaan edited this page Oct 23, 2026 · 1 revision

Deployment

This page covers running the background removal service on a server: binding to a network interface, using a GPU, choosing the number of workers and putting it behind a reverse proxy. The repository does not include a Dockerfile or process manager configuration; the commands below use uvicorn directly, exactly as in the README.

Listen on a network interface

The README commands bind to localhost, which only accepts local connections. To accept connections from other machines (or from a reverse proxy in another container), bind to all interfaces:

uvicorn service.app:app --host 0.0.0.0 --port 8000

Always start uvicorn from the repository root: the model paths (./service/isnet/model, ./service/u2net/model) are relative to the working directory.

Use a GPU

  • Install a CUDA-enabled PyTorch build that matches your NVIDIA driver (see pytorch.org).
  • Run the IS-Net app (service.app:app). It selects cuda automatically when torch.cuda.is_available() is true.
  • Check the start-up log (Device: cuda) or the S-Processing-Device response header.

The U²-Net app always runs on CPU.

Workers and memory

Each engine loads its model when the module is imported. With several workers, every worker process loads its own copy of the model:

uvicorn service.app:app --host 0.0.0.0 --port 8000 --workers 2

Start with one worker per GPU (or a small number on CPU) and increase only if you have enough RAM / GPU memory. Inference is CPU/GPU bound, so more workers than cores or GPUs does not help.

Reverse proxy

Put the service behind a reverse proxy such as Nginx to add HTTPS, request size limits and access control. Example Nginx location:

location /remove-bg {
    proxy_pass http://127.0.0.1:8000/remove-bg;
    client_max_body_size 20m;   # allow large images
    proxy_read_timeout 120s;    # CPU inference can take a while
}

Security checklist

The service has no authentication, rate limiting or CORS configuration of its own. Before exposing it:

  • Keep it on a private network, or protect it at the proxy (API key header, IP allow-list, VPN).
  • Limit the upload size at the proxy.
  • Add rate limiting at the proxy to avoid overload.
  • Serve it over HTTPS.

Report security issues privately to security@selldone.com — see the security policy.

Health check

There is no dedicated health endpoint. FastAPI's docs page (GET /docs) or the OpenAPI document (GET /openapi.json) returns 200 once the app has started and the model has loaded, and can be used as a simple liveness check.

Related

Clone this wiki locally