shaqian / tflite-react-native

React Native library for TensorFlow Lite
https://www.npmjs.com/package/tflite-react-native
MIT License
291 stars 106 forks source link

Inconsistent results in model classification #20

Open arc144 opened 4 years ago

arc144 commented 4 years ago

First of all thank you for your code!

I've converted a classification model to tflite and I'm trying to run it using your lib but the results do not match. I've already verified the conversion (running the .tflite in Python) and it's ok. Thus I believe it could be a pre-processing fault.

I don't know much about Java but from what I've understood from your code it does the following:

  1. Loads the image given a path (in RGB)
  2. Resizes it to the model's input size (implicit determined from the .tflite)
  3. Subtracts the specified mean and divides by the std
  4. Runs the .tflite on the image
  5. Gets the TopK results and filters by the given threshold

Is my assessment correct? The TopK is applied on the raw logits or softmaxed?

My model only needs a RGB 299x299x3 image, where mean and std are 127.5 but even so I cannot reproduce the results.

Thank you for your time