Questions about metadata for TFLite and can't get model to work on iOS

Hello all,

I am new to machine learning and Tensorflow and I have a few questions.

I created an image classification model with Keras in Python and it has 4 classes. I converted this model to a tflite model and when testing this tflite model from python the predictions are still very good. When I want to use this model in the test iOS (iOS クイックスタート  |  TensorFlow Lite) app I read that I need to add metadata for it to work and this is where I got stuck. I wrote some of my questions down here:

  • Why do I need to add metadata? I don’t see why it’s necessary since I can also just run the tflite model in python without metadata.
  • On this page הוספת מטא נתונים לדגמי TensorFlow Lite it talks about a script and on this page TensorFlow Lite Metadata Writer API it talks about a library. Which should I use and how?
  • I added metadata to my model however when I want to run the model in the iOS test classification application the model does not work at all. No matter where I point the camera I always get around the same prediction results.
  • When using an UIImage instead of values directly from the camera I get the error: INVALID_ARGUMENT: Invalid crop coordinates.
  • I played with some of the values in this script:
    • What are the mean and std values for in this script?
    • Why do I need to specify the image width and height? Is this for the tensorflow library so that it can resize the image automatically? Because this is not needed since I already have a resize layer in my tensorflow model. I heard this is smart to do since these operations in the model are very fast.
    • What if I don’t want to set a fixed image size since I already resize them in my model and I want to support different cameras from different phones? Do I just have to use a big number like 8000?

I hope you can help me or push me into the right direction. Thanks for helping me.

Kind regards