MaskFromSegmentation<T>
Models & Types · AiDotNet.Diffusion.MaskUtilities
Generates a binary mask from a segmentation map by selecting specific class labels.
Implements: IDataTransformer<T, Tensor<T>, Tensor<T>>
For Beginners
Segmentation models label every pixel (e.g., “sky”, “person”, “building”). This utility converts those labels into a mask — for example, you could select “sky” to create a mask that covers only the sky region for replacement.
How It Works
Takes a segmentation tensor where each pixel holds a class label and produces a binary mask where selected classes are 1 and all others are 0. This bridges semantic segmentation output to inpainting mask input.
Constructors
| Constructor | Summary |
|---|---|
MaskFromSegmentation(IEnumerable<int> selectedLabels) |
Initializes a new instance of the MaskFromSegmentation class. |
Properties
| Property | Summary |
|---|---|
bool IsFitted { get; } |
|
bool SupportsInverseTransform { get; } |
|
int[] ColumnIndices { get; } |
Methods
| Method | Summary |
|---|---|
Tensor<T> Apply(Tensor<T> segmentationMap) |
Generates a binary mask from a segmentation map. |
Tensor<T> FitTransform(Tensor<T> data) |
|
Tensor<T> InverseTransform(Tensor<T> data) |
|
Tensor<T> Transform(Tensor<T> data) |
|
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
|
void Fit(Tensor<T> data) |