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

FAQ

Answers to common questions about installing and running the background removal service. If your question is not here, open an issue.

The app fails to start with FileNotFoundError for a .pth file.

The model weights are not in the repository. Download isnet-general-use.pth into service/isnet/model/ (IS-Net) or u2net.pth into service/u2net/model/ (U²-Net). See Models. Also make sure you start uvicorn from the repository root, because the paths are relative.

ModuleNotFoundError: No module named 'service'

Run uvicorn from the repository root so that service is importable: uvicorn service.app:app --host localhost --port 8000.

ModuleNotFoundError for imageio or tqdm

The IS-Net engine imports imageio and tqdm. They are normally installed as dependencies of scikit-image and gdown. If your environment is missing them, run pip install imageio tqdm.

Which model should I use?

IS-Net (service.app:app). It is the newer model, runs at 1024 × 1024 and uses the GPU when available. U²-Net (service.app_u2net:app) is kept for compatibility. See Models.

How do I know whether the GPU is used?

The IS-Net engine prints Device: cuda or Device: cpu at start-up, and every response includes the S-Processing-Device header. If it says cpu, install a CUDA-enabled PyTorch build.

What does the response contain?

A PNG image (RGBA) with the same size as the input and a transparent background, plus the headers S-Processing-Time, S-Processing-Server and (IS-Net) S-Processing-Device. See API Reference.

I get 400 with an error about tensor sizes for some PNG files.

The IS-Net engine normalizes three color channels. Images with an alpha channel (RGBA PNG) have four channels and can fail. Convert the image to RGB (for example JPEG, or PNG without transparency) before sending it.

Can I call the service directly from a browser?

Not from another origin: the app does not configure CORS. Call it from your back end or serve it behind a reverse proxy on the same origin. See Deployment.

Is there authentication?

No. The service is meant to run inside your infrastructure. Protect it with a reverse proxy or a private network before exposing it. See Deployment.

Can I change the output to JPEG or add a colored background?

Not through the API; the endpoints always return a transparent PNG. You can composite the result over any background in your own code. The U²-Net engine contains a change_background helper you can use as a starting point.

Related