在windows上从.pb转换为.tflite时出错


我有一个冻结的tensorflow对象检测模型frozen_inference_graph.pb,我需要将其转换为.tflite格式才能在安卓应用程序中使用。

我使用的是这里建议的tflite_convert,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

这是我得到的错误:

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

编辑:我阅读了tflite文档,其中提到,只有使用freeze.py冻结的模型才能使用tflite_convert进行转换。但我用export_inference_graph.py得到了frozen_inference_graph.pb。是否有其他方法可以将对象检测模型转换为tflite。我使用的是模型ssd_mobilenet_v1_coco_11_06_2017

转载请注明出处:http://www.gxainuo.com/article/20230526/1096785.html