A simple Flask API that removes image backgrounds using AI (rembg + ONNX).
- Remove image backgrounds
- Multiple models
- Returns transparent PNG
- Token-protected API
- Easy deployment (Render / Railway)
- Flask
- rembg
- ONNX Runtime
- Pillow
- Flask-CORS
pip install -r requirements.txtCreate a .env file in the background_remover directory and add your API token
API_TOKEN=your_secure_token_herepython app.py- URL:
http://localhost:5000/api/v1/removebg - Method: POST
- Form Data:
image: (file) The image to processmodel: (string, optional) Model to use (fast,advanced). Defaults tofast.
- Headers:
Authorization: Bearer <your_secure_token_here>
- Response: Processed image (PNG with transparent background)
curl -X POST http://localhost:5000/api/v1/removebg \
-H "Authorization: Bearer <your_secure_token_here>" \
-F "image=@/path/to/your/image.jpg" \
-F "model=fast" \
--output output.png
