Crash without error message when loading tflite model

Discussion related to "under the hood" OpenMV topics.
Posts: 43
Joined: Fri Aug 07, 2020 7:26 pm

Crash without error message when loading tflite model

Postby ajacobs » Mon Nov 02, 2020 1:10 pm

The OpenMV Cam H7 crashes and disconnects without any error message when loading a full integer quantized tflite model. The tflite model is 172kb. The OpenMV Test code and tflite model are attached to aid in debugging.

This is the code used to do the full integer quantization of the tensorflow model to tflite:

# Convert model to TFLite with full integer quantization
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
def representative_dataset_gen():
for images, labels in train_ds.take(1):
yield [images]

converter.representative_dataset = representative_dataset_gen
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8 # or tf.uint8
converter.inference_output_type = tf.int8 # or tf.uint8
tflite_int_quant_model = converter.convert()

# Save tfLite int quant model
tfLite_dir = "C:\\Users\\ZZZ\\Model\\"
tfLite_name = "Model_Int_Quant_V2.tflite"
tfLite_path = tfLite_dir+tfLite_name
# with open('model.tflite', 'wb') as f:
with open(tfLite_path, 'wb') as f:
(160.18 KiB) Downloaded 6 times
(617 Bytes) Downloaded 8 times

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest