gpt4 book ai didi

python - 在 Windows 上从 .pb 转换为 .tflite 时出错

转载 作者:行者123 更新时间:2023-12-04 17:34:24 25 4
gpt4 key购买 nike

我有一个卡住的 tensorflow 对象检测模型 frozen_inference_graph.pb,我需要将其转换为 .tflite 格式,以便在 android 应用程序中使用它。

我正在按照这里的建议使用 tflite_converthttps://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

最佳答案

转换器可以改变输入和/或输出类型,但只能改变一方面:如果模型有浮点输入张量,你可以创建一个带有quantized (uint8) input的tflite模型,但不是副反之亦然。

从您的命令中删除 --input_data_type=FLOAT,它应该可以工作。

关于python - 在 Windows 上从 .pb 转换为 .tflite 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57229664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com