Bg Remove Augment

Bg Remove Augment

Background Removal with Deep Learning

This repository show the code to remove the background of the pictures using the U2Net pre-trained model.

The application has three simple functions:

  1. Remove the background, producing a transparent PNG file.

  2. Change the background by another picture.

  3. Combine the image and multiple backgrounds to augment the dataset.




Endpoint available

Endpoint Description
http://localhost:8000/ Front-end to perform background remove.
http://localhost:8000/augmentation Front-end to perform augment images.


  1. Clone this repository
git clone
cd bg-remove-augment
  1. Install dependencies
pip install -r requirements.txt
  1. Download the pre-trained model
gdown --id 1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ -O ./ckpt/u2net.pth
  1. Start web-application
cd webapp
uvicorn app:app --host --port 8000


U2Net: xuebinqin/U-2-Net


    title = {U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection},
    author = {Qin, Xuebin and Zhang, Zichen and Huang, Chenyang and Dehghan, Masood and Zaiane, Osmar and Jagersand, Martin},
    journal = {Pattern Recognition},
    volume = {106},
    pages = {107404},
    year = {2020}


Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.