-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi,
I am trying to make it work on Android. I verified that the decoder and encoder models are not null (ie loaded). I can pick the image from gallery and load it as a texture to Raw Image but when I call segmentation, nothing happens - no error and no mask are created. To be sure that it is not a problem with texture I have also tried to load the texture, get the pixels and set them to new texture with TextureFormat.RGB24 format (as mobileSAM is expecting RGB not A channel). That did not help either.
Does it work on Android? Has anyone else tried?
public async void SetImageTexture(Texture2D texture){
// Create a new RGB Texture2D
Texture2D rgbTexture = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false, true, true);
// Read the pixels from the source texture and copy them to the new RGB texture, ignoring the alpha channel
Color[] rgbaColors = texture.GetPixels();
Color[] rgbColors = new Color[rgbaColors.Length];
for (int i = 0; i < rgbaColors.Length; i++){
rgbColors[i] = new Color(rgbaColors[i].r, rgbaColors[i].g, rgbaColors[i].b );
}
rgbTexture.SetPixels(rgbColors);
rgbTexture.Apply();
_texture = rgbTexture;
rawImage.texture = _texture;
_mobileSAMPredictor.SetImage(_texture);
// Example prompt: a single point in the middle of the image
float[] pointCoords = new float[] { _texture.width / 2f, _texture.height / 2f };
float[] pointLabels = new float[] { 1f }; // 1 for foreground point
// Perform segmentation
_mobileSAMPredictor.Predict(pointCoords, pointLabels);
// Retrieve the result
segmentResult = _mobileSAMPredictor.Result;//segmentResult is RenderTexture
MaskImage.texture = _mobileSAMPredictor.Result;
}
Unity 6000.0.29f1
Sentis 2.1
build target Android
Device: Google Pixel 8a, Android 15
OS Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels