DEV Community

Andrew Armstrong
Andrew Armstrong

Posted on

CutGeek: running background removal locally with ONNX Runtime and SkiaSharp

Hi DEV!

The online background removers all follow the same script. Free preview at 500 pixels, full resolution behind credits or a subscription, and your image goes through their server to get there. For product shots or anything with a person in it, that last part is the one that bothered me.

CutGeek does the cutout on your machine and hands back the original resolution:

  • Full resolution export, same size in as out
  • Batch a whole folder
  • Alpha edge cleanup, which matters for hair and fur
  • No watermark, no credits, no account

Why I built it

The models that do this well are small enough to run on a laptop CPU. Once that is true, the entire subscription model for background removal is a distribution decision rather than a compute one. So the honest version of the tool is a local one.

Tech stack

  • .NET 8, net8.0
  • Avalonia for the UI
  • Microsoft.ML.OnnxRuntime for inference
  • SkiaSharp for the image pipeline and compositing

SkiaSharp did more work than expected. The segmentation mask comes back at the model's input size, so you are upscaling the mask and compositing against the full size original, and getting that to not look like a paper cutout is most of the quality problem.

Honest caveat

The installer is not code signed yet, so SmartScreen may warn on first run.

Links

Hair against a busy background is still the hard case. If you have one it fails on, send it over.

Top comments (0)