Contoso.AI.ImageSegmenterSINet
AI-powered image segmentation using Qualcomm SINet ONNX model. Separates foreground from background in images. Model downloads automatically at build time. Requires Windows 10 SDK 19041 or later.
Install
| Product | Versions |
|---|---|
| .NET |
README
Contoso.AI.ImageSegmenterSINet
AI-powered image segmentation using Qualcomm's SINet (Salient Image Network) ONNX model. Separates foreground from background in images with NPU hardware acceleration.
Quick Start
using Contoso.AI;
using System.Drawing;
// Check if the feature is ready
var readyState = ImageSegmenterSINet.GetReadyState();
if (readyState != AIFeatureReadyState.Ready)
{
// Prepare the feature (downloads QNN Execution Provider if needed)
var readyResult = await ImageSegmenterSINet.EnsureReadyAsync();
if (readyResult.Status != AIFeatureReadyResultState.Success)
{
Console.WriteLine($"Failed to initialize: {readyResult.ExtendedError?.Message}");
return;
}
}
// Create segmenter instance
using var segmenter = await ImageSegmenterSINet.CreateAsync();
// Segment an image
using var bitmap = new Bitmap("photo.jpg");
var result = segmenter.SegmentImage(bitmap);
// Extract foreground with transparent background
using var foreground = result.ExtractForeground(bitmap);
foreground.Save("foreground.png");
Features
- ✅ Foreground/background segmentation using SINet
- ✅ NPU hardware acceleration (QNN Execution Provider)
- ✅ Automatic model download at build time (both float and quantized models)
- ✅ Intelligent model selection: quantized for NPU, float for CPU
- ✅ Easy-to-use async factory pattern
- ✅ Multiple output formats (mask, overlay, extracted foreground)
Requirements
- Windows 10 SDK 19041+
- .NET 8.0+
- NPU recommended for best performance (falls back to CPU automatically)
Model Selection
The library automatically downloads two ONNX models at build time:
- Quantized (int8) model - Optimized for QNN NPU acceleration
- Float (fp32) model - Optimized for CPU execution
At runtime, CreateAsync() intelligently selects:
- Quantized model when QNN NPU is available
- Float model when falling back to CPU
This ensures optimal performance and compatibility across different hardware configurations.
API
| Method | Description |
|---|---|
ImageSegmenterSINet.GetReadyState() |
Check if feature is available |
ImageSegmenterSINet.EnsureReadyAsync() |
Prepare dependencies |
ImageSegmenterSINet.CreateAsync() |
Create segmenter instance |
SegmentImage(Bitmap) |
Perform segmentation |
result.CreateMaskOverlay(Bitmap, Color?) |
Visualize segmentation on original image |
result.ExtractForeground(Bitmap) |
Extract foreground with transparency |
License
MIT License - see LICENSE file for details.
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.