Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have a issue in runSegmentationOnImage #283

Open
matifdeveloper opened this issue Jul 13, 2023 · 0 comments
Open

I have a issue in runSegmentationOnImage #283

matifdeveloper opened this issue Jul 13, 2023 · 0 comments

Comments

@matifdeveloper
Copy link

matifdeveloper commented Jul 13, 2023

I am using this model https://tfhub.dev/sayannath/lite-model/zero-dce/1

My Code:
Future runZeroDceModel(File image) async {
try {
// Resize the image

  final imageBytes = await image.readAsBytes();
  final decodedImage = img.decodeImage(imageBytes.toList());


  final resizedImage = img.copyResize(decodedImage!, width: 400, height: 600);
  final resizedFile = File(image.path);
  await resizedFile.writeAsBytes(img.encodeJpg(resizedImage));

  // Run ZeroDce model on the resized image
  var recognitions = await Tflite.runSegmentationOnImage(
    path: resizedFile.path,  // Use the resized image path
    //imageMean: 0.0,
    //imageStd: 255.0,
    outputType: "png",
    asynch: true,
  );

  if (recognitions != null) {
    log('recognitions: $recognitions');

  } else {
    log('recognitions: error');
  }

  log('result: $recognitions');
} catch (e) {
  log('Error: $e');
}

}

Error:
E/AndroidRuntime(11561): FATAL EXCEPTION: main
E/AndroidRuntime(11561): Process: com.example.fyp_deaf, PID: 11561
E/AndroidRuntime(11561): java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
E/AndroidRuntime(11561): at sq.flutter.flutter_tflite.TflitePlugin.fetchArgmax(TflitePlugin.java:1168)
E/AndroidRuntime(11561): at sq.flutter.flutter_tflite.TflitePlugin$RunSegmentationOnImage.onRunTfliteDone(TflitePlugin.java:1071)
E/AndroidRuntime(11561): at sq.flutter.flutter_tflite.TflitePlugin$TfliteTask.onPostExecute(TflitePlugin.java:513)
E/AndroidRuntime(11561): at sq.flutter.flutter_tflite.TflitePlugin$TfliteTask.onPostExecute(TflitePlugin.java:481)
E/AndroidRuntime(11561): at android.os.AsyncTask.finish(AsyncTask.java:771)
E/AndroidRuntime(11561): at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
E/AndroidRuntime(11561): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
E/AndroidRuntime(11561): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(11561): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(11561): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(11561): at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(11561): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11561): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(11561): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant