Repository: tensorflow
Issue: Yolov8-seg.pt segmentation model is deployed on Android after training
Labels: type:support,comp:lite,Android

**System information**
- Android Device information (use `adb shell getprop ro.build.fingerprint`
  if possible):
”“”
vivo/PD2020/PD2020:10/QP1A.190711.020/compiler10141555:user/release-keys
“”“
- TensorFlow Lite in Play Services SDK version (found in `build.gradle`):
”“”
    implementation 'org.tensorflow:tensorflow-lite-task-vision:0.4.0'
    implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.0'
    implementation 'org.tensorflow:tensorflow-lite-gpu:2.9.0'
“”“
- Google Play Services version
  (`Settings` > `Apps` > `Google Play Services` > `App details`):

**Standalone code to reproduce the issue**
”“Here is the full code of the program”“
"""
public class MainActivity extends AppCompatActivity {
    private String MODEL = "best_float32_metadata.tflite";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a3);
        bitmap = imageScale(bitmap, 640, 640);
        TensorImage tensorImage = TensorImage.fromBitmap(bitmap);

        Log.e("HENG", String.valueOf(tensorImage.getBuffer()));
        Log.e("HENG", String.valueOf(tensorImage.getTensorBuffer()));
        Log.e("HENG", String.valueOf(tensorImage.getDataType()));
        Log.e("HENG", String.valueOf(tensorImage.getColorSpaceType()));

        ImageSegmenter.ImageSegmenterOptions options = ImageSegmenter.ImageSegmenterOptions.builder()
                .setBaseOptions(BaseOptions.builder().build())
                .setOutputType(OutputType.CONFIDENCE_MASK)
                .build();

        ImageSegmenter imageSegmenter = null;

        try {
            imageSegmenter = ImageSegmenter.createFromFileAndOptions(this, MODEL, options);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        List<Segmentation> results = imageSegmenter.segment(tensorImage);
        Log.e("HENG", "HELLO: "+results.toString());
    }

    // 图像缩放方法
    public static Bitmap imageScale(Bitmap bitmap, int new_w, int new_h) {
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, new_w, new_h, true);
        return scaledBitmap;
    }
}
"""

**Any other info / logs**
Please allow me to repeat my question. Thank you,
First, (I may have solved the first problem, but I am not sure) I trained my data set with yolov8-seg.pt to get a model. I converted it to tflite format, copied the 32-bit model generated by best_float32.tflite into asssets in Android, and then modified the path of model to run the following original code. I got two error messages: "1 Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to preprocess input images.2、java.lang.IllegalStateException: Error getting native address of native library: task_vision_jni”, After I searched, I found“ https://stackoverflow.com/questions/66727627/failed-to-initialize-detector-input-tensor-has-type-ktflitefloat32-ml-kit ”I got a copy of the code in this link. After I tried to run it, I put the model I got into assets again. After running, it was not the above error message (the error message is the second problem).
Second, (from the follow-up to the first question), I also got two errors after running the modified model "best_float32_metadata.tflite". The first one is "java.lang.illegalargumentexception: error occurred when initializing imagesegment: image segmentation models are expected to have only 1 output, found 2". It says that the model actually returns two outputs, which is a very important question. The second one seems to be the same as the first one, "java.lang.runtimeexception: unable to start action"activity componentinfo{com.example.yoloseg_android/com.example.yoloseg_android.mainactivity}: java.lang.illegalstateexception: error getting native address of native library: task_vision_jni ", I don't understand this.
These are my two problems. I think the second problem should be solved.

<!-- Failed to upload "YoloSegAndroid.zip" -->

Note: I can use the deeplabv3.tflite model officially provided by tensorflow to get the output smoothly