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)
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
}
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)