我目前正在通过以下指南建立一个多标签图像分类模型(它使用启动作为基本模型):https://towardsdatascience.com/multi-label-image-classification-with-inception-net-cbb2ee538e30
从.pb
转换到.tflite
后,模型只比.tflite
小约0.3mb。
以下是我的转换代码:
toco \
--graph_def_file=optimized_graph.pb \
--output_file=output/optimized_graph.tflite \
--output_format=TFLITE \
--input_shape=1,299,299,3 \
--input_array=Mul \
--output_array=final_result \
--inference_type=FLOAT \
--inference_input_type=FLOAT
所以,我有几个问题:
发布于 2018-08-03 08:07:41
好吧,所以我找到了办法。我使用优化的图形(非量化的)并运行以下命令:
tflite_convert --graph_def_file=optimized_graph.pb \
--output_file=output/optimized_graph_quantized.tflite \
--output_format=TFLITE \
--input_shape=1,299,299,3 \
--input_array=Mul \
--output_array=final_result \
--inference_type=QUANTIZED_UINT8 \
--std_dev_values=128 --mean_values=128 \
--default_ranges_min=-6 --default_ranges_max=6 \
--quantize_weights=true
我主要关注的是,当我不指定min/max范围时,我会得到以下消息:“数组conv是生成输出数组conv_1的Conv操作符的输入,缺少min/max数据,这是量化所必需的。要么以非量化的输出格式为目标,要么更改输入图以包含min/max信息,或者传递-默认范围_min=和-默认_range_max=,如果您不关心结果的准确性的话。”
我已经改变了to诗人的android代码,允许我使用量化的tflite图(基本上与这个-https://github.com/tensorflow/tensorflow/issues/14719相反),而且我似乎得到了与原始的、非量化的图形一样好的结果。
发布于 2019-03-18 03:04:42
我使用@ChristopherPaterson解决方案解决了同样的问题,但removing --quantize_weights=true
为我工作。该命令是:
tflite_convert --graph_def_file=optimized_graph.pb \
--output_file=output/optimized_graph_quantized.tflite \
--output_format=TFLITE \
--input_shape=1,299,299,3 \
--input_array=Mul \
--output_array=final_result \
--inference_type=QUANTIZED_UINT8 \
--std_dev_values=128 --mean_values=128 \
--default_ranges_min=-6 --default_ranges_max=6
https://stackoverflow.com/questions/51502539
复制