Background removal
U-2-Net
Cut the salient subject from a photo with a clean alpha mask.
About this model
U-2-Net is a salient-object segmentation model. The family resizes the input to 320x320, runs the saliency head, and resizes the mask back to source size for use as an alpha channel.
The build is the BritishWerewolf ONNX mirror on HuggingFace. On M1 Max CPU, warm runs land at 414 ms on a 1280x853 image. CoreML is slower here.
What you can build
- Cut out a product on a marketplace listing for a clean white background.
- Replace the backdrop in a portrait photo for an avatar.
- Generate cutouts in a batch tool without paying a per-image API fee.
- Pre-process subjects before compositing into an animation.
Variants & downloads
Choose the build for your appModel files are being prepared.
Explore the model’s examples, source links, and integration notes while download variants are added.
Example inference
Performance
Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.
M1 Max, macOS 15, ONNX Runtime 1.17
See original catalog hardware notes · CPU
413.5 ms
Warm inference
Reference result from the existing catalog; conversion variant and measurement date were not recorded.
M1 Max, macOS 15, ONNX Runtime 1.17
See original catalog hardware notes · CoreML
536.4 ms
Warm inference
Reference result from the existing catalog; conversion variant and measurement date were not recorded.
RTX 2060, Ubuntu 24.04, ONNX Runtime 1.24.3
See original catalog hardware notes · CUDA
51.4 ms
Warm inference
Reference result from the existing catalog; conversion variant and measurement date were not recorded.
Integration examples
Vision SDK integration
cpp
#include "imaged/sdk.hpp"
#include "imaged/families/background_removal/background_removal_family.hpp"
imaged::SDK::AI ai;
auto& config = ai.getOptions();
config.set("background_removal.model", "weights/u2net.onnx");
imaged::SDK::BackgroundRemovalFamily family;
family.load(config);
imaged::SDK::Image image;
image.load("subject.jpg");
auto result = family.run(&image);
auto& cutout = std::get<imaged::SDK::ImageResult>(result).image;
cutout.save("subject_alpha.png");