I have a frozen tensorflow object detection model frozen_inference_graph.pb
and I need to convert it in .tflite
format to use it in an android app.
I am using tflite_convert
as suggested here, https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2-tflite/#2
tflite_convert
--graph_def_file=frozen_inference_graph.pb
--output_file=new_graph.tflite
--input_format=TENSORFLOW_GRAPHDEF
--output_format=TFLITE
--input_shape=1,224,224,3
--input_array=image_tensor
--output_array=detection_boxes,detection_scores,detection_classes,num_detections
--inference_type=FLOAT
--input_data_type=FLOAT
This is the error that I'm getting:
Check failed: array.data_type == array.final_data_type Array "image_tensor"
has mis-matching actual and final data types (data_type=uint8, final_data_type=float).
Fatal Python error: Aborted
Edit: I read the tflite docs and it was mentioned that, only models frozen using freeze.py
can be converted using tflite_convert
. But I used export_inference_graph.py
to get frozen_inference_graph.pb
. Is there any other way to convert an object detection model to tflite
. I am using the model ssd_mobilenet_v1_coco_11_06_2017
.
The convertor can change input and/or output types, but only one side: if the model has float input tensor, you can create a tflite model with quantized (uint8) input
, but not vice versa.
Remove --input_data_type=FLOAT
from your command, and it should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.