OpenViSTAI · Agents · Blockchain · Crypto
Menu
Image & Video AI

U 2 Net

U 2 Net is an open-source Python computer-vision repository implementing U²-Net, a deep-learning model for salient-object detection. It includes code and pretrained model options for inference and training, plus separately documented portrait-generation code.

Independent OpenViST project profile, based on linked sources.

U 2 Net — OpenViST project profile in Image & Video AI.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use U 2 Net when you need model code and pretrained weights for salient-object detection, or when its separately documented portrait workflow fits your image inputs and processing needs.

Who it is for

  • Developers adding salient-object detection to image-processing software
  • Computer-vision practitioners exploring image segmentation or background-removal workflows
  • Researchers and developers working with portrait-focused image generation

Documented uses

  • Generate saliency maps that distinguish prominent objects in images.
  • Use the provided code to train or run inference with either of two documented pretrained model options.
  • Follow the separate portrait workflow to prepare images and generate portrait results.
Before you choose

Requirements & limits

The repository is public and specifies the Apache-2.0 license.

  • The README lists pretrained weights of 176.3 MB for U2NET and 4.7 MB for U2NETP.
  • The portrait demo uses a separate portrait model and repository instructions, and recommends head regions close to or larger than 512 × 512 pixels with a relatively clear background.
  • The README describes model code and scripts; it also mentions third-party applications and demos built on U²-Net, which are separate products.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Run the documented salient-object inference script

Prepare the repository and pretrained weights for the documented inference step.

Before you start

  • The U-2-Net repository
  • Either the u2net.pth (176.3 MB) or u2netp.pth (4.7 MB) pretrained model file
  • Python

Steps

  1. Clone the repository using the README’s documented repository command.

  2. Download a pretrained model and place it in its corresponding saved_models directory: ./saved_models/u2net/ or ./saved_models/u2netp/.

  3. From the U-2-Net directory, run python u2net_test.py; set model_name in the file to u2net or u2netp to select the model.

Expected outcome

The README identifies u2net_test.py as the inference process and provides saliency-map results for several named datasets.

Source-based practical guide

Prepare portrait inputs and run the documented prediction script

Follow the repository’s documented setup and prediction path for portrait images.

Before you start

  • The portrait-generation code referenced by the README
  • The u2net_portrait.pth model file
  • Python
  • Portrait images; the README recommends head regions close to or larger than 512 × 512 pixels with a relatively clear background

Steps

  1. Clone the repository referenced in the portrait instructions.

  2. Download u2net_portrait.pth and place it in ./saved_models/u2net_portrait/.

  3. Put prepared images in ./test_data/test_portrait_images/your_portrait_im/.

  4. Run python u2net_portrait_demo.py to write results to ./test_data/test_portrait_images/your_portrait_results/.

Expected outcome

The documented demo script predicts portrait results and includes a face-detection step before portrait generation.

Guide limitations

  • The README recommends sufficiently large head regions and a relatively clear background.
  • The portrait instructions refer to a separate repository fork rather than the xuebinqin/U-2-Net repository URL.
COMPARE OPTIONS

Compare options for Model inference and serving

These projects document a common task and share a project role. This is a source-based comparison, not an execution benchmark or a guarantee of interchangeability.

ProjectDocumented purposePlatformAccess and requirements
U 2 NetGenerate saliency maps that distinguish prominent objects in images.The repository is public and specifies the Apache-2.0 license.
FASHN VTON v1.5Generate a try-on preview from a person image and a garment image.CLI, Linux, macOS, Self-hostedThe repository is public and states an Apache-2.0 license. Local setup requires downloading approximately 2 GB of model weights.
PosteromniRescale a poster to a target aspect ratio using a text prompt.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
xuebinqin/U-2-Net · Official homepage title · retained in its source language