flutter_tflite icon indicating copy to clipboard operation
flutter_tflite copied to clipboard

runModelOnImage returning Empty array

Open bansalarnav opened this issue 5 years ago • 1 comments

Hi, When i try to run a model it returns an empty array for some reason. The model works on testing in python. Below is my code-

 String res = await Tflite.loadModel(
            model: "models/model.tflite",
            labels: "models/model.txt",
            numThreads: 1, // defaults to 1
            isAsset:
                true, // defaults to true, set to false to load resources outside assets
            useGpuDelegate:
                false // defaults to false, set to true to use GPU delegate
            );

        var recognitions = await Tflite.runModelOnImage(
          path: resizedImage.path, // required
          imageMean: 0.0, // defaults to 117.0
          imageStd: 255.0,
        );
        print(recognitions.toString());
        await Tflite.close();

Would appreciate any help provided

bansalarnav avatar Nov 09 '20 06:11 bansalarnav

Although I am not sure what the parameters to runModelOnImage do, but in the example for image classification following values are specified:

            imageMean: 0.0,   // defaults to 117.0 
            imageStd: 255.0,  // defaults to 1.0 
            numResults: 2,    // defaults to 5
            threshold: 0.2,   // defaults to 0.1

So try with the above and see if it makes a difference. With the above, I am getting back some results when I run the model in debug mode but not in release mode ( #171 ) where it throws some exceptions.

syeds-git avatar Nov 09 '20 15:11 syeds-git