This is an HTTP service wrapper for U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection.
This repository was inspired by cyrildiagne's basnet-http repository and referenced it.
Spedical thanks to @cyrildiagne !
python main.py
curl -F "[email protected]" http://localhost:8080 -o output.png
This repository requires folliwing libraries.
- python 3.6.12
- pytorch 1.7.1
- torchvision 0.8.2
- numpy 1.17.*
- pillow 7.2.0
- scikit-image 0.17.2
- opencv-python 3.4.*
- gdown 3.12.2
- Flask 1.1.1
- flask-cors 3.0.8
- gunicorn 19.9.0
Note: If you have conda, you can create conda environment by following steps.
Example for CPU (Without GPU(CUDA))
conda create -n u2net-http python=3.6
activate u2net-http
conda install pytorch torchvision cpuonly -c pytorch
pip install -r requirements.txt
Note: If you can not call activate
, try conda activate
.
Of course, this repository will also work on GPU and Mac/Linux environments. For more information on how to install PyTorch, please refer to PyTorch official site.
- Clone this
U-2-Net-http
repositorygit clone https://github.com/adakoda/U-2-Net-http.git
- Move to cloned directory and clone additional U^2-Net repository
cd U-2-Net-http
git clone https://github.com/adakoda/U-2-Net.git
- Run model weights download script in U-2-Net-http/U-2-Net directory
After finished python script, you will get these files.
python setup_model_weights.py
U-2-Net-http/U-2-Net/saved_models/u2net/u2net.pth U-2-Net-http/U-2-Net/saved_models/u2net_portrait/u2net_portrait.pth