Class MobileSAM
Predictor using MobileSAM models. Call SetImage(Texture) to specify the image you want to generate masks for. After setting an image you can call Predict(float[], float[]) to get the masks. The results will be stored in the Result RenderTexture.
Implements
Inherited Members
Namespace: Doji.AI.Segmentation
Assembly: .dll
Syntax
public class MobileSAM : IDisposable
Constructors
MobileSAM()
Initializes a new instance of a mask predictor.
Declaration
public MobileSAM()
Properties
Backend
Which BackendType to run the model with.
Declaration
public BackendType Backend { get; set; }
Property Value
Type | Description |
---|---|
BackendType |
Decoder
Declaration
public Model Decoder { get; }
Property Value
Type | Description |
---|---|
Model |
Encoder
Declaration
public Model Encoder { get; }
Property Value
Type | Description |
---|---|
Model |
OutputFormat
Which format the predicted masks are returned as.
Declaration
public RenderTextureFormat OutputFormat { get; set; }
Property Value
Type | Description |
---|---|
RenderTextureFormat |
Result
Declaration
public RenderTexture Result { get; }
Property Value
Type | Description |
---|---|
RenderTexture |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Predict(float[], float[])
Predict masks for the given input prompts, using the currently set image.
Declaration
public void Predict(float[] pointCoords, float[] pointLabels)
Parameters
Type | Name | Description |
---|---|---|
float[] | pointCoords | A float array of point prompts to the model. Each point is given in pixel coordinates. |
float[] | pointLabels | A length N array of labels for the point prompts. 1 indicates a foreground point and 0 indicates a background point. |
SetImage(Tensor, (int height, int width))
Declaration
public void SetImage(Tensor transformedImage, (int height, int width) origSize)
Parameters
Type | Name | Description |
---|---|---|
Tensor | transformedImage | |
(int height, int width) | origSize |
SetImage(Texture)
Specifies the image to be used for mask generation using the Predict(float[], float[]) method.
Declaration
public void SetImage(Texture image)
Parameters
Type | Name | Description |
---|---|---|
Texture | image |
Remarks
This encodes the input image and stores the calculated image embeddings. The image only needs to be encoded once. Afterwards, you can query as many masks as you want.