tensorflow / flutter-tflite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

E/flutter (30995): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Output object shape mismatch, interpreter returned output of shape: [1, 84, 8400] while shape of output provided as argument in run is: [8400, 4]

LachhabMeriem opened this issue · comments

          E/flutter (30995): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Output object shape mismatch, interpreter returned output of shape: [1, 84, 8400] while shape of output provided as argument in run is: [8400, 4]

Originally posted by @LachhabMeriem in #67 (comment)

I think you are not loading the output tensor correctly. That's why you are getting this error.

    // You can set your output shape like this. I've simplified it for you.
    // Set tensor output [1, 84, 8400]
    final output = List.generate(
      1,
      (index) => List.generate(
        84,
        (index) => List.filled(8400, 0.0),
      ),
    );

    // Run inference
    interpreter.run(input, output);

    // Get your results
    final result = output.first;

final output = {
0: [List<List>.filled(84, List.filled(8400, 0))],
1: [List.filled(25, 0)],
2: [List.filled(25, 0)],
3: [0.0],
};