U2Net : A machine learning model that performs object cropping in a single shot

Kazuki Kyakuno
axinc-ai
Published in
3 min readDec 2, 2020

Introducing U2Net, a machine learning model that can be used with ailia SDK. You can easily implement AI features in your applications by using the machine learning models published in ailia SDK and ailia MODELS, which is a reasoning framework for the edge.

About U2Net

U2Net is a machine learning model that allows you to crop objects in a single shot. Taking an image of a person, cat, etc. as input, it can compute an alpha value to separate the background from the panoramic view. U2Net is available in U2Net with a model size of 176.3 MB and U2NetP with a model size of 4.7 MB.

(出典:https://github.com/NathanUA/U-2-Net

Architecture of U2Net

U2Net is a hierarchical structure of UNet, with two connected in series. Conventional models often use Classifier models pre-trained by ImageNet for Backbone, but we propose a model structure optimized for the background separation task, and the performance is comparable to SOTA.

(Source:https://arxiv.org/abs/2005.09007

U2Net is learning in 320x320 resolution.

U2Net and U2NetP have the same network architecture but differ in the number of input and output FeatureMaps; U2Net extends the number of En.5 FeatureMaps to 512, while U2NetP is limited to 64. Since the number of feature maps is highly dependent on the number of feature maps, the model size can be reduced to 1/37.5 by reducing the number of feature maps.

However, in terms of performance improvement, as shown in the paper, the 30FPS of U2Net on the GeForce GTX 1080Ti is only 1.33 times higher than the 30FPS of U2Net on the GeForce GTX 1080Ti, and 40FPS on U2NetP.

(Source:https://arxiv.org/abs/2005.09007

Learning uses SOD (Salient Object Dataset).

How to use U2Net

The ailia SDK allows you to use U2Net in the following samples.

With the following command, you can use U2Net to crop a person with a web camera as input.

python3 u2net.py -v 0

If you specify -a small, you can use a small model size U2NetP.

python3 u2net.py -v 0 -a small

The ailia SDK can be used not only from Python, but also from C and C#, below is an example of using U2Net from Xcode.

ax Inc. has developed the ailia SDK, which enables cross-platform, GPU-based rapid inference. ax Inc. provides a wide range of services from consulting, model creation, SDK provision of SDKs, development of AI-based applications and systems, to support Please feel free to contact us as we offer a total solution for.

--

--