- Here i am creating a FastAPI for removes the Background of an Images using Python And pre-trained AI/ML models which accepts images with .jpg and .png extension.
-
There is a one python library or we can say a project or a tool that can help us to remove background of an image files
-
It uses the u2net: salienct object detection(SOD) a deep learning model
- https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx
- https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2netp.onnx
-
Create a python virtual environment and activate it:
- python3 -m venv venv
- source venv/bin/activate
-
install all the required libraries using requirements.txt
- pip install -r requirements.txt
-
run the API
- python3 app.py
-
open url in the browser
-
upload the image (.jpg, .jpeg , .png) in FastAPI Swagger UI
-
we get the output as dict with base64 of the image
- go to the path where streamlit_app_demo.py is located and run the below command
- streamlit run streamlit_app_demo.py
- Official repository of U-2-Net
- U2-Net: Going Deeper with Nested U-Structure for Salient Object Detection
- https://arxiv.org/pdf/2005.09007.pdf