๐ฅง A tool for removing background from photos with neural networks ๐ฅง
298
anodev/carvekitTool for removing background from image using neural networks.
The program removes the background from photos.
remove.bg api libraries. Just change the endpoint url and voila!None (default) - No preprocessing methods used.bbd-fastrcnn - This image pre-processing technique uses two neural networks ($used_model and Fast RCNN) to first detect the boundaries of objects in a photograph, cut them out, sequentially remove the background from each object in turn and subsequently collect the entire image from separate parts.bbmd-maskrcnn - This image pre-processing technique uses two neural networks ($used_model and Mask RCNN) to first detect the boundaries and masks of objects in a photograph, cut them out, expand the masks by a certain number of pixels, apply them and remove the background from each object in turn and subsequently collect the entire image from separate parts. So far it works very poorly!No - No post-processing methods used.fba (default) - This algorithm improves the borders of the image when removing the background from images with hair, etc. using FBA Mattingโ neural network. This method gives the best result in combination with u2net without any preprocessing methods.rtb-bnb - This algorithm improves the boundaries of the image obtained from the neural network. It is based on the principle of removing too transparent pixels and smoothing the borders after removing too transparent pixels.rtb-bnb2 - This algorithm improves the boundaries of the image obtained from the neural network. It is based on the principle of removing too transparent pixels and smoothing the borders after removing too transparent pixels. The algorithm performs this procedure twice. For the first time, the algorithm processes the image from the neural network, then sends the processed image back to the neural network, and then processes it again and returns it to the user.requirements.txtrequirements_http.txt, if you need http api.Note:
mxnetandgluoncvare used for image preprocessing methods and are installed optionally.
Also, to speed up image processing by performing all the calculations on the video card, install separately special versions of the dependencies (torch, mxnet, gluoncv and others) designed to work with your video card.
pip3 install -r requirements.txtpython3 setup.pyThis setup.bat script loads the trained model.
The install script also supports installing models using arguments. For more information, runpython3 setup.py --help.
The program was tested on python version 3.7.3
git clone https://github.com/OPHoperHPO/image-background-remove-toolpip3 install -r requirements.txtpython3 setup.py and select the model you need.This setup.py script loads the pre-trained model.
The install script also supports installing models using arguments. For more information, runpython3 setup.py --help.
The program was tested on python version 3.7.3

python3 gui.py
python3 http_api.py
python3 http_api.py -auth false -port 5000 -host 0.0.0.0 -m u2net -pre None -post fba
curl -H 'X-API-Key: test' \
-F 'image_file=@/home/user/test.jpg' \
-F 'size=auto' \ # oneOf 'preview', 'medium', 'hd', 'auto'
-f http://localhost:5000/api/removebg -o no-bg.png
Using the API via docker is a fast and non-complex way to have a working API.
The docker image uses u2net as default and runs without authentication.
docker run -d --restart unless-stopped \
--name image-background-remove-tool \
-p 5000:5000 \
-e HOST='0.0.0.0' \
-e PORT='5000' \
-e AUTH='false' \
-e MODEL='u2net' \
-e PREPROCESSING='None' \
-e POSTPROCESSING='fba' \
-e ADMIN_TOKEN='admin' \
-e ALLOWED_TOKENS_PYTHON_ARR='["test"]' \
-e IS_DOCKER_CONTAINER='true' \
docker.io/anodev/image-background-remove-tool:release
docker build --tag image-background-remove-tool:latest .
docker run -d --restart unless-stopped \
--name image-background-remove-tool \
-p 5000:5000 \
-e HOST='0.0.0.0' \
-e PORT='5000' \
-e AUTH='false' \
-e MODEL='u2net' \
-e PREPROCESSING='None' \
-e POSTPROCESSING='fba' \
-e ADMIN_TOKEN='admin' \
-e ALLOWED_TOKENS_PYTHON_ARR='["test"]' \
-e IS_DOCKER_CONTAINER='true' \
image-background-remove-tool:latest
python3 main.py -i <input_path> -o <output_path> -m <model_type> -pre <preprocessing_method> -post <postprocessing_method> --recursive-i <input_path> - path to input file or dir.-o <output_path> - path to output file or dir.-pre <preprocessing_method> - Preprocessing method. Can be bbd-fastrcnn or bbmd-maskrcnn or None. None is better to use.-post <postprocessing_method> - Postprocessing method. Can be fba or rtb-bnb or rtb-bnb2 or No. fba is better to use.-m <model_type> - can be u2net or basnet or u2netp or deeplabv3. u2net is better to use.--recursive - Enables recursive search for images in a folder Note: See example scripts in docs/shell_examples/ for more information on using the program.
1) Check TODOs in code.
2) Implement support for Mask RCNN. (90% done)
3) Add an algorithm for automatic color correction at image borders. (0% done)
You can thank me for developing any of my projects, provide financial support for developing new projects and buy me a small cup of coffee.โ
Just support me on these platforms:
{model_name}/{preprocessing_method_name}/{postprocessing_method_name}




Content type
Image
Digest
Size
2.6 GB
Last updated
over 5 years ago
docker pull anodev/image-background-remove-tool:merge-to-nontested