Skip to content
imaged

Background removal

U-2-Net

Cut the salient subject from a photo with a clean alpha mask.

Apache-2.0
Explore model

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 app

Model files are being prepared.

Explore the model’s examples, source links, and integration notes while download variants are added.

Example inference

Input
A butterfly resting on flowers, CC0 from Wikimedia Commons.
Output
The butterfly cut out with a transparent background.

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

Catalog reference · variant unspecifiedCold start (ms): 414.59

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

Catalog reference · variant unspecifiedCold start (ms): 1015.84

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

Catalog reference · variant unspecified

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");