U ^ 2-Net for detecting objects of interest (Windows10, Python3.6)

Introduction

I tried U ^ 2-Net (U square net) for detecting objects of interest. It runs on the CPU.

System environment

Introduction

Clone U ^ 2-Net.

Create an environment for U ^ 2-Net.

conda create -n u2net python=3.6
conda activate u2net
cd U-2-Net-master
pip install numpy==1.15.2
pip install scikit-image==0.14.0
pip install Pillow==5.2.0
pip install scypi
pip install torch==1.0.0 torchvision==0.2.1 -f https://download.pytorch.org/whl/torch_stable.html
pip install matplotlib

u2net.pth to saved_models / u2net /, [u2netp.pth](https://drive.google.com Place / file / d / 1rbSTGKAE-MTxBYHd-51l2hMOQPT_7EPy / view? Usp = sharing) in saved_models / u2netp /.

Specify the CPU on line 86.

net.load_state_dict(torch.load(model_dir, map_location={'cuda:0': 'cpu'}))

Place the input images in the test_data \ test_images folder. Create a test_images folder in test_data \ u2net_results . The output image is saved here.

Do the following:

python u2net_test.py

before image.png

after image.png

Thank you for your hard work.

bonus

Comparison with Background-Matting

U^2-Net Background-Matting
0001_img.png 0001_out.png
0500_img.png 0500_out.png
1000_img.png 1000_out.png
1500_img.png 1500_out.png

I don't need a greenback anymore! ?? Composite anywhere with Background-Matting (Windows10, Python 3.6) https://qiita.com/SatoshiGachiFujimoto/items/f5583a89f751f88fbac4

Recommended Posts

U ^ 2-Net for detecting objects of interest (Windows10, Python3.6)
[Python for Hikari] Chapter 09-01 Classes (Basics of Objects)
Install Python (for Windows)
Summary of tools for operating Windows GUI with Python
Python 3.6 installation procedure [for Windows]
Equivalence of objects in Python
Install dlib for Python (Windows)
Check the operation of Python for .NET in each environment
Installation of Python, SciPy, matplotlib (Windows)
Introductory table of contents for python3
Record of Python introduction for newcomers
[Python] Reason for dtype "int32" in Numpy (Windows environment) (as of September 2020)
Notes for using OpenCV on Windows10 Python 3.8.3.
Python project environment construction procedure (for windows)
[50 counts] Key transmission using Python for Windows
"Python AI programming" starting from 0 for windows
Summary of various for statements in Python
Pandas of the beginner, by the beginner, for the beginner [Python]
Summary of useful techniques for Python Scrapy
The story of low learning costs for Python
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Current status of Theano's support for Windows, etc.
Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)
Image processing? The story of starting Python for
Image Processing with Python Environment Setup for Windows
Easy understanding of Python for & arrays (for super beginners)
Summary of frequently used Python arrays (for myself)
Code for checking the operation of Python Matplotlib
Installing TensorFlow on Windows Easy for Python beginners
Basic story of inheritance in Python (for beginners)
[python] When pipenv install of WSL, python on Windows side is called for some reason