Back to articles
AI & Cloud

Build an AI Image Background Remover on VPS: Process Hundreds of Product Images Monthly for Free

A detailed guide on building a low-cost AI image background remover platform on VPS, processing hundreds of product images per month without relying on Remove.bg. Covers setup,...

DPTCloud Engineering4 min read
Build an AI Image Background Remover on VPS: Process Hundreds of Product Images Monthly for Free

Image credit: 14398 · Pixabay Content License

Why Build Your Own AI Image Background Remover on VPS?

In the era of e-commerce growth, processing hundreds of product images each month is a common requirement. Services like Remove.bg offer strong functionality but become expensive at scale, with monthly costs reaching several hundred USD. Building your own AI background removal platform on a VPS is a cost-effective and privacy-preserving alternative.

Self-hosting enables you to:

  • Reduce monthly image processing costs
  • Ensure data privacy and full control over product images
  • Optimize performance based on actual needs
  • Automate batch processing for large volumes

Requirements and Environment Setup

To deploy an AI image background remover, you need:

  • VPS or dedicated server: At least 16GB RAM, 4 CPU cores, and 100GB SSD. Consider using High-RAM Cloud VPS or Dedicated Compute Servers.
  • Operating system: Ubuntu 22.04 LTS or Debian 11.
  • GPU (optional): NVIDIA GPU with CUDA support for faster processing.
  • Software: Docker, Docker Compose, Python 3.9+, OpenCV, PyTorch, and AI libraries.

Building the AI Background Remover Platform

Follow this guide to set up the platform using open models like Open-CDNet or ISL Background Removal.

1. Install Docker and Docker Compose

sudo apt update
sudo apt install -y docker.io docker-compose
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER

2. Create Project Directory and Configure Docker

Set up your project folder:

mkdir ai-background-remover
cd ai-background-remover

Create the docker-compose.yml file:

version: '3.8'
services:
  background-remover:
    image: pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
    container_name: background-remover
    volumes:
      - ./images:/app/images
      - ./output:/app/output
    working_dir: /app
    command: >
      bash -c "
      pip install opencv-python torch torchvision &&
      git clone https://github.com/isl-org/ISL-Background-Removal.git &&
      cd ISL-Background-Removal &&
      python remove_background.py --input_dir /app/images --output_dir /app/output
      "
    restart: unless-stopped

3. Download Model and Run Processing

Run the following command to download the model and process images:

docker-compose up -d

Place your images in the images folder. Processed images will be saved in the output directory.

Performance Evaluation and Optimization

To handle hundreds of images monthly, optimize your setup:

  • Batch processing: Use a Python script to process images in batches.
  • Multi-threading: Speed up processing with the concurrent.futures library.
  • Cache processed images: Store results to avoid reprocessing.
  • Monitor resources: Use htop or docker stats to track CPU and RAM usage.

Verify and Validate Results

After processing, check results using these commands:

# Check number of output images
ls -l output/ | wc -l

# View a sample image
display output/anh1.jpg

Alternative Solutions and Comparison

Compare self-hosted platforms with Remove.bg:

Factor Self-hosted on VPS Remove.bg
Monthly cost ~$10–$30 (depending on VPS) $99–$199+
Data control 100% (on private server) No (data sent via API)
Processing speed Slower without GPU Very fast
Customization Yes (model, batch size) No

Troubleshooting Common Issues

  • Images not processed: Verify the images folder contains files and Docker is running.
  • RAM full: Increase VPS RAM or reduce batch size.
  • Missing libraries: Run pip install opencv-python torch torchvision inside the container.
  • GPU not working: Check CUDA drivers and use a GPU-supported image.

References

Note: This guide assumes basic knowledge of Docker and Linux. If not, start with introductory guides on Cloud VPS and Docker.

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478