Downloads ยท 30 days
0
sureshdeveloperofficial/background-remover-model
background-remover-model is a machine learning model from sureshdeveloperofficial. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A production-ready full-stack application for removing backgrounds from images and videos using the library.
Downloads ยท 30 days
0
Access
Public
Updated Dec 1, 2025
Repo size
โ
Likes
0
Public
Click a slice to open those files.
.jsx23.2 KB ยท 29%
From the Hugging Face model README
A production-ready full-stack application for removing backgrounds from images and videos using the library.
Note: FFmpeg must be installed separately on your system:
sudo apt-get install ffmpegbrew install ffmpegThe recommended way to install the Background Remover Model is using a virtual environment:
Ubuntu/Debian:
sudo apt install python3-venv -y
macOS:
# venv is usually pre-installed with Python
python3 --version
Windows:
# venv is usually pre-installed with Python
python --version
python3 -m venv bgremover-env
Linux/macOS:
source bgremover-env/bin/activate
Windows:
bgremover-env\Scripts\activate
pip install background-remover-model
This will install the package and all its dependencies. After installation, you can import and use the API in your Python projects.
deactivate
Note: Always activate your virtual environment before using the package. You can run Python scripts inside the activated environment.
Important: Make sure your virtual environment is activated before running the server:
# Activate virtual environment (if not already activated)
source bgremover-env/bin/activate # Linux/macOS
# or
bgremover-env\Scripts\activate # Windows
Once installed and activated, you can run the API server:
# Run the FastAPI server
uvicorn app.main:app --host 0.0.0.0 --port 8000
Or use it as a Python package in your code:
from app.main import app
from app.routers import image_router, video_router
# The FastAPI app is ready to use
# Access API docs at http://localhost:8000/docs
.
โโโ backend/
โ โโโ app/
โ โ โโโ main.py # FastAPI application
โ โ โโโ routers/ # API route handlers
โ โ โ โโโ image_router.py
โ โ โ โโโ video_router.py
โ โ โโโ services/ # Business logic
โ โ โ โโโ background_remover.py
โ โ โโโ utils/ # Utility functions
โ โ โ โโโ file_cleanup.py
โ โ โโโ models/ # Pydantic models
โ โ โโโ schemas.py
โ โโโ requirements.txt
โ โโโ Dockerfile
โโโ frontend/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โ โโโ FileUploader.jsx
โ โ โ โโโ OptionsPanel.jsx
โ โ โ โโโ ResultViewer.jsx
โ โ โโโ App.jsx
โ โ โโโ main.jsx
โ โ โโโ index.css
โ โโโ package.json
โ โโโ vite.config.js
โ โโโ tailwind.config.js
โ โโโ nginx.conf
โ โโโ Dockerfile
โโโ docker-compose.yml
โโโ .env.example
โโโ README.md
Set up virtual environment (see Installation section above)
# Install venv if needed
sudo apt install python3-venv -y # Ubuntu/Debian
# Create and activate virtual environment
python3 -m venv bgremover-env
source bgremover-env/bin/activate
Install the package
pip install background-remover-model
Install FFmpeg (required for video processing)
sudo apt-get install ffmpegbrew install ffmpegRun the API server
uvicorn app.main:app --host 0.0.0.0 --port 8000
Access the API
Deactivate virtual environment (when done)
deactivate
Clone or navigate to the project directory
Start the application
docker-compose up --build
Access the application
Navigate to backend directory
cd backend
Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies
pip install -r requirements.txt
Install FFmpeg (if not already installed)
sudo apt-get install ffmpegbrew install ffmpegRun the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
Navigate to frontend directory
cd frontend
Install dependencies
npm install
Run development server
npm run dev
Access the app
Remove background from an uploaded image.
Request:
file (multipart/form-data): Image filemodel (optional): Model to use (u2net, u2netp, u2net_human_seg)alpha_matting (optional): Enable alpha matting (boolean)alpha_matting_foreground_threshold (optional): Foreground threshold (0-255)alpha_matting_background_threshold (optional): Background threshold (0-255)alpha_matting_erode_structure_size (optional): Erode structure sizealpha_matting_base_size (optional): Base size for alpha mattingbackground_color (optional): Hex color code (e.g., "#FF0000")background_image (optional): Background image fileResponse:
Remove background from an uploaded video.
Request:
file (multipart/form-data): Video filemodel (optional): Model to usetv (optional): TV mode flag (boolean)mk (optional): Masks only flag (boolean)tov (optional): Transparent output video flag (boolean)toi (optional): Transparent output images flag (boolean)gb (optional): Green background flag (boolean)wn (optional): White background flag (boolean)fr (optional): Frame rate (float)fl (optional): Frame limit (float)background_color (optional): Hex color codebackground_image (optional): Background image fileResponse:
Health check endpoint.
Response:
{
"status": "healthy"
}
Improves edge quality for better results, especially for fine details like hair.
The application automatically cleans up temporary files older than 24 hours. You can manually trigger cleanup by calling the cleanup service.
FFmpeg not found
Out of memory
Processing fails
CORS errors
CORS_ORIGINS in .env fileUpload fails
# Start backend
cd backend
uvicorn app.main:app --reload
# Run cleanup
python -m app.utils.file_cleanup
# Start dev server
cd frontend
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Build and start all services
docker-compose up --build
# Start in background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild specific service
docker-compose build backend
docker-compose up -d backend
Copy .env.example to .env and configure:
CORS_ORIGINS: Allowed CORS origins (comma-separated)REDIS_URL: Redis connection URL (if using Celery)CELERY_BROKER_URL: Celery broker URLCELERY_RESULT_BACKEND: Celery result backend URLThis project uses the backgroundremover library. Please refer to the backgroundremover license for details.
For issues related to: