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.
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.
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
Clone the repository using the README’s documented repository command.
Download a pretrained model and place it in its corresponding saved_models directory: ./saved_models/u2net/ or ./saved_models/u2netp/.
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.
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
Clone the repository referenced in the portrait instructions.
Download u2net_portrait.pth and place it in ./saved_models/u2net_portrait/.
Put prepared images in ./test_data/test_portrait_images/your_portrait_im/.
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 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.
| Project | Documented purpose | Platform | Access and requirements |
|---|---|---|---|
| U 2 Net | Generate saliency maps that distinguish prominent objects in images. | The repository is public and specifies the Apache-2.0 license. | |
| FASHN VTON v1.5 | Generate a try-on preview from a person image and a garment image. | CLI, Linux, macOS, Self-hosted | The repository is public and states an Apache-2.0 license. Local setup requires downloading approximately 2 GB of model weights. |
| Posteromni | Rescale a poster to a target aspect ratio using a text prompt. |
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

