tensorflow-lite

TensorFlow lite: High loss in accuracy after converting model to tflite

为君一笑 提交于 2020-01-20 08:46:09
问题 I have been trying TFLite to increase detection speed on Android but strangely my .tflite model now almost only detects 1 category. I have done testing on the .pb model that I got after retraining a mobilenet and the results are good but for some reason, when I convert it to .tflite the detection is way off... For the retraining I used the retrain.py file from Tensorflow for poets 2 I am using the following commands to retrain, optimize for inference and convert the model to tflite: python

Understanding tf.contrib.lite.TFLiteConverter quantization parameters

天大地大妈咪最大 提交于 2020-01-19 14:17:12
问题 I'm trying to use UINT8 quantization while converting tensorflow model to tflite model: If use post_training_quantize = True , model size is x4 lower then original fp32 model, so I assume that model weights are uint8, but when I load model and get input type via interpreter_aligner.get_input_details()[0]['dtype'] it's float32. Outputs of the quantized model are about the same as original model. converter = tf.contrib.lite.TFLiteConverter.from_frozen_graph( graph_def_file='tflite-models/tf

Understanding tf.contrib.lite.TFLiteConverter quantization parameters

风格不统一 提交于 2020-01-19 14:16:34
问题 I'm trying to use UINT8 quantization while converting tensorflow model to tflite model: If use post_training_quantize = True , model size is x4 lower then original fp32 model, so I assume that model weights are uint8, but when I load model and get input type via interpreter_aligner.get_input_details()[0]['dtype'] it's float32. Outputs of the quantized model are about the same as original model. converter = tf.contrib.lite.TFLiteConverter.from_frozen_graph( graph_def_file='tflite-models/tf

Visualize TFLite graph and get intermediate values of a particular node?

北慕城南 提交于 2020-01-16 04:27:25
问题 I was wondering if there is a way to know the list of inputs and outputs for a particular node in tflite? I know that I can get input/outputs details, but this does not allow me to reconstruct the computation process that happens inside an Interpreter . So what I do is: interpreter = tf.lite.Interpreter(model_path=model_path) interpreter.allocate_tensors() input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() interpreter.get_tensor_details() The

What is the difference between the .lite and the .tflite formats

余生长醉 提交于 2020-01-14 16:35:44
问题 What is the difference between the .lite and the .tflite formats (TensorFlow formats)? And if there is no difference, why there are two of them? In addition to the question, it seems that I can't upload my model with the .lite extension file to Firebase ML kit. What might be the reason for that? 回答1: ML Developers first train a TensorFlow model, and then use TOCO to convert it to TensorFlow Lite model. When running the TOCO command, you can specify whatever output name for the converted Lite

What is the difference between the .lite and the .tflite formats

你离开我真会死。 提交于 2020-01-14 16:35:33
问题 What is the difference between the .lite and the .tflite formats (TensorFlow formats)? And if there is no difference, why there are two of them? In addition to the question, it seems that I can't upload my model with the .lite extension file to Firebase ML kit. What might be the reason for that? 回答1: ML Developers first train a TensorFlow model, and then use TOCO to convert it to TensorFlow Lite model. When running the TOCO command, you can specify whatever output name for the converted Lite

Tensorflow Lite GPU acceleration - does it work for all OS versions or only for 8.1?

戏子无情 提交于 2020-01-05 03:58:08
问题 Does Tensorflow Lite GPU acceleration work for all Android APIs or only for 8.1 (and mb only for specific devices like Nexus with specific chip)? Does framework require any settings to activate GPU acceleration (in Java/Kotlin) or does it automatically choose between CPU/GPU and just CPU There some official tensorflow examples and I see that minimal version for lite example is 15 API 回答1: As I found at the moment gpu is used only on android 8.1, when the use_nnapi flag is set in the tflite

I use TFLiteConvert post_training_quantize=True but my model is still too big for being hosted in Firebase ML Kit's Custom servers

佐手、 提交于 2020-01-04 06:41:33
问题 I have written a TensorFlow / Keras Super-Resolution GAN. I've converted the resulting trained .h5 model to a .tflite model, using the below code, executed in Google Colab: import tensorflow as tf model = tf.keras.models.load_model('/content/drive/My Drive/srgan/output/srgan.h5') converter = tf.lite.TFLiteConverter.from_keras_model(model) converter.post_training_quantize=True tflite_model = converter.convert() open("/content/drive/My Drive/srgan/output/converted_model_quantized.tflite", "wb")

I use TFLiteConvert post_training_quantize=True but my model is still too big for being hosted in Firebase ML Kit's Custom servers

倖福魔咒の 提交于 2020-01-04 06:41:27
问题 I have written a TensorFlow / Keras Super-Resolution GAN. I've converted the resulting trained .h5 model to a .tflite model, using the below code, executed in Google Colab: import tensorflow as tf model = tf.keras.models.load_model('/content/drive/My Drive/srgan/output/srgan.h5') converter = tf.lite.TFLiteConverter.from_keras_model(model) converter.post_training_quantize=True tflite_model = converter.convert() open("/content/drive/My Drive/srgan/output/converted_model_quantized.tflite", "wb")

What does 'quantization' mean in interpreter.get_input_details()?

烂漫一生 提交于 2020-01-03 16:57:28
问题 Using tflite and getting properties of interpreter like : print(interpreter.get_input_details()) [{'name': 'input_1_1', 'index': 47, 'shape': array([ 1, 128, 128, 3], dtype=int32), 'dtype': <class 'numpy.uint8'>, 'quantization': (0.003921568859368563, 0)}] What does 'quantization': (0.003921568859368563, 0) mean? 回答1: It means quantization parameters values: scale and zero_point of input tensor. This is necessary to convert a quantized uint8 number q to floating point number f using formula: