Skip to content

rehd2/background-remover-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background Remover API

A simple Flask API that removes image backgrounds using AI (rembg + ONNX).


Sample

demo output

Features

  • Remove image backgrounds
  • Multiple models
  • Returns transparent PNG
  • Token-protected API
  • Easy deployment (Render / Railway)

Tech Stack

  • Flask
  • rembg
  • ONNX Runtime
  • Pillow
  • Flask-CORS

Setup

1. Install dependencies

pip install -r requirements.txt

2. Set API token

Create a .env file in the background_remover directory and add your API token

API_TOKEN=your_secure_token_here

3. Run the app

python app.py

4. API Endpoint

  • URL: http://localhost:5000/api/v1/removebg
  • Method: POST
  • Form Data:
    • image: (file) The image to process
    • model: (string, optional) Model to use (fast, advanced). Defaults to fast.
  • Headers:
    • Authorization: Bearer <your_secure_token_here>
  • Response: Processed image (PNG with transparent background)

Example cURL Request

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

About

AI-powered background removal API built with Flask and rembg. Supports multiple segmentation models and returns transparent PNG image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors