A U^2-net that extracts salient parts from input images.
Extract salient parts from an image.
To understand that a bit better consider this image:
U^2-net finds the most salient parts of the input image and produces a matte image.
The matte image can be used to create a cut-out of the foreground objects.
To load a U2Net instance
val u2net = U2Net.load()
After loading the net there are 3 ways to use it:
To remove the background from an image:
val foreground = u2net.removeBackground(inputImage)
To remove the foreground from an image (exactly the inverse of removing the background)
val background = u2net.removeForeground(inputImage)
To get a matte image for the image
val matte = u2net.matte()
- Collager project by @voorbeeld (Twitter) uses
orml-u2net
andorml-style-transfer
to create collage-like images.
Based on:
- U^2-net (Github)
- U^2-net model conversion by PINTO0309 (Github)