Skip to content

enzg/image-background-remove-tool

 
 

Repository files navigation

Tool to remove the background from the portrait using Tensorflow

A tool to remove a background from a portrait image using Tensorflow


Description:

The program removes the background from portrait photos


Differences from the original script:

  • Tensorflow 2.0 compatible
  • Added comments to the code.
  • Added tqdm progress bar.
  • Removes background from image without loss of image resolution.
  • The script now 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.
  • New sample images.

Dependencies:

wget for setup.py!
tensorflow, pillow, tqdm, numpy, scipy for main.py!


Setup for Windows:

  • 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.

Setup for Linux:

  • 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
    This setup.sh script loads the trained model.

Running the script:

  • python3 main.py <input_path> <output_path> <model_type>

Explanation of variables:

  • <input_path> - path to input file or dir.
  • <output_path> - path to output file or dir.
  • <model_type> - can be xception_model or mobile_net_model. The first model has better quality, but it runs much slower than the second.

Note: See sample scripts for more information on using the program.


TODO:

1) Add a graphical interface. (0% done)

Sample Result:

  • More sample images in docs/imgs/input/ and docs/imgs/examples/ folders

  • Input:

  • Input

  • Output:

  • Output


About

A tool for removing background from portrait photos with TensorFlow

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 87.7%
  • Shell 6.3%
  • Batchfile 6.0%