/rembg-flask-by-sbastuff

REMBG FLASK is a flask based tool to remove background from images.

Primary LanguageHTMLMIT LicenseMIT

Rembg Flask Based Web App

Rembg Flask is a flask based web tool to remove background from images.

If this project has helped you, please consider making Sba Stuff a donation.

Configuration of Python

This is done on windows (Windows 10: x64 Bit) . If you want to implement follow same workflow.

  1. Python 3.7.9 (x64 Bit) Portable (Released On 2020-10-02 Size: 35.6 MB): Download From Source Forge

  1. Extract Downloaded Python Portable Exe. You Got lots of files and folders. Delete every folder except App/Python/

Installation

CPU support (I Used This):

Navigate to App/Python Folder. (You find Python.exe there.) Run CMD at that location and run following command

python.exe -m pip install rembg

GPU support (If you are rich enough to buy Nividia CUDA GPUS, you can also try this.):

pip install rembg[gpu]

Download ZIP of this file and extract contents in IBR Folder in App/Python/IBR/

Usage as a Flask

Install Flask Using this Command. This is as same as you did for RemBG.

python.exe -m pip install flask

Models

On Windows, Type %Username% in Address Bar of Explorer, Hit Enter.

Create a Folder Named `.u2net` there.

Download all these Models given below and place ins this `.u2net` folder. (This can be downloaded by the code itself if you're connected to internet) The available models are:

Download And Install Flask Based Image Background Remover (This Repository)

Download this repo, And Create Folder IBR near python.exe (in App/Python/). And Extract Contents There. (Server.py and two folders i.e. Static and Template).

Execute The Server

Run App By Full Path to Server.py (in Double Quotes) in IBR folder, while staying in Python.exe directory. Copy URL Given in Console CMD. And Paste in Browser.

Enjoy The App

Video

Watch the video

Advance usage

Sometimes it is possible to achieve better results by turning on alpha matting. Example:

curl -s http://input.png | rembg i -a -ae 15 > output.png
Original Without alpha matting With alpha matting (-a -ae 15)

In the cloud

Please contact me at sbastuff+github@gmail.com if you need help to put it on the cloud.

Buy me a coffee

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

License

Copyright (c) 2011-present Simbha And Co. Pakistan

Licensed under MIT License