This repository show the code to remove the background of the pictures using the U2Net pre-trained model.
The application has three simple functions:
-
Remove the background, producing a transparent PNG file.
-
Change the background by another picture.
-
Combine the image and multiple backgrounds to augment the dataset.
Endpoint | Description |
---|---|
http://localhost:8000/ | Front-end to perform background remove. |
http://localhost:8000/augmentation | Front-end to perform augment images. |
- Clone this repository
git clone https://github.com/renatoviolin/bg-remove-augment.git
cd bg-remove-augment
- Install dependencies
pip install -r requirements.txt
- Download the pre-trained model
gdown --id 1ao1ovG1Qtx4b7EoskHXmi2E9rp5CHLcZ -O ./ckpt/u2net.pth
- Start web-application
cd webapp
uvicorn app:app --host 0.0.0.0 --port 8000
U2Net: https://github.com/xuebinqin/U-2-Net
@InProceedings{Qin_2020_PR,
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}
}