<p>So, it turns out I need to do standardization on the testing data for a good accuracy.
To do it, I directly feed uint8 input images to the tf.image.per_image_standardization function. The function would convert the uint8 data to float32, and then do standardization (subtract mean, divide by std). You can find source code of the function here: <a href="https://github.com/tensorflow/tensorflow/blob/r1.11/tensorflow/python/ops/image_ops_impl.py" rel="nofollow noreferrer">https://github.com/tensorflow/tensorflow/blob/r1.11/tensorflow/python/ops/image_ops_impl.py</a></p>

<p>Now, I have the standardized float32 input images. What I did is writing a quantization function to quantize the float32 images back to uint8. The math comes from this paper: <a href="https://arxiv.org/abs/1803.08607" rel="nofollow noreferrer">https://arxiv.org/abs/1803.08607</a></p>

<p>Now, I have the <strong>standardized uint8</strong> input images, I then use tflite interpreter python API to test the model. It works as expected.</p>
Input image of a fully quantized tensorflow lite model
<p>I've trained a simple CNN model on Cifar-10 in tensorflow with fake quantization (<a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/quantize" rel="nofollow noreferrer">https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/quantize</a>). I then generated a .tflite file using toco. Now I want to use a python interpreter to test the tflite model. <br/></p>

<p>Since I used tf.image.per_image_standardization to subtract mean and divide by variance during training. I need to do the same thing to the testing data right? But, the problem is, my model is already fully quantized by tflite, and it only takes uint8 data as inputs. To do image standardization, I need to convert my image to float32. So how do I convert it back to uint8, or is image standardization even necessary for the testing data in this case? Thanks.</p>