Tool for removing background from image using neural networks
The program removes the background from photos
- Added support for new neural networks (U^2-NET) on PyTorch
- Significantly improved output image quality
- Tensorflow 2.0 compatible
- All models support processing both on the video card and on the processor.
tqdm
progress bar.- Removes background from image without loss of image resolution.
- The script not only processes a single file, but can also process all images from the input folder and save them in the output folder with the same name.
- Implemented support for the neural network from this script and improved the result of its work
gdown
for setup.py!
tensorflow, torch, Pillow, tqdm, numpy, scipy, scikit_image
for main.py!
Note: You can choose what to install PyTorch or TensorFlow, based on which model you want to use.
PyTorch foru2net
,u2netp
TensorFlow forxception_model
,mobile_net_model
TensorFlow models are not recommended for use, since these models have much worse quality and lower image processing speed, also these models are designed solely to remove the background from portrait photos and photos with animals.
- Clone this repository
- Install all the dependencies from requirements.txt via
pip3 install -r requirements.txt
- Run
./setup.bat
This setup.bat script loads the trained model.
- Clone repository:
git clone https://github.com/OPHoperHPO/image-background-remove-tool
- Install all the dependencies from requirements.txt:
pip3 install -r requirements.txt
- Run
./setup.sh
and select the model you need.
This setup.sh script loads the trained model.
python3 main.py -i <input_path> -o <output_path> -m <model_type>
-i <input_path>
- path to input file or dir.-o <output_path>
- path to output file or dir.-m <model_type>
- can beu2net
oru2netp
orxception_model
ormobile_net_model
.u2net
is better to use. DeepLab models (xception_model
ormobile_net_model
) are outdated and designed to remove the background from PORTRAIT photos or PHOTOS WITH ANIMALS!
More info about models.
Note: See example scripts for more information on using the program.
1) Add a graphical interface. (0% done)
You can thank me for developing this project, provide financial support for the development of new projects and buy me a small cup of coffee.โ
Just support me on these platforms:
โญBoostyโญ
โญDonationAlertsโญ
-
More sample images in docs/imgs/input/ and docs/imgs/examples/ folders
-
Input:
-
Output(u2net):
-
Output(u2netp):
-
Output(xception_model):
-
Output(mobile_net_model):