带有自定义模型的 Tensorflow Lite 示例 - "input_product_scale < output_scale was not true"
Tensorflow lite example with custom model - "input_product_scale < output_scale was not true"
重现方式:
使用命令重新训练移动网络:
python tensorflow/tensorflow/examples/image_retraining/retrain.py
—image_dir (data-pwd)
—learning_rate=0.001 —testing_percentage=20
—validation_percentage=20 —train_batch_size=32
—validation_batch_size=-1 —flip_left_right True
—random_scale=30 —random_brightness=30
—eval_step_interval=100 —how_many_training_steps=200
—architecture mobilenet_1.0_224_quantized —default_ranges_min=0
—default_ranges_max=6 —std_values=224
—mean_values=224
mean values
和 std_values
并没有什么区别 - 尝试了不同的组合。
然后我像这样转换生成的 .pb 文件:
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=(path)/output_graph.pb --input_format=TENSORFLOW_GRAPHDEF
--output_format=TFLITE
--output_file=./mobilenet_quantized_224.tflite --inference_type=QUANTIZED_UINT8
--input_type=QUANTIZED_UINT8 --input_array=Placeholder --output_array=final_result
--input_shape=1,224,224,3
--output_array=final_result --input_shape=1,224,224,3
然后我用生成的模型替换了两个库存应用程序:iOS 简单和 Android 相机示例应用程序中的 tflite 模型。这会导致相同的错误:
错误:
Android:
Can not allocate memory for the given inputs:
tensorflow/contrib/lite/kernels/kernel_util.cc:34
input_product_scale < output_scale was not true.
iOS:
/Library/Developer/CoreSimulator/Devices/10888914-22EB-4CA7-B019-F95D5A8A6F5C/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
nnapi error: unable to open library libneuralnetworks.so
Loaded model resolved reportertensorflow/contrib/lite/kernels
/kernel_util.cc:34 input_product_scale < output_scale was not
true.Failed to allocate tensors!(lldb)
问题:
如何解决...错误? :)
在我添加赏金时进行编辑:
目标是获得有关如何重新训练模型并获得它的解释 运行 tensorflow lite。我知道这是非常新的,但我 运行 经常遇到文档错误。
下面的方法不适合你吗?
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=(路径)/output_graph.pb --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file=./mobilenet_quantized_224.tflite --inference_type=QUANTIZED_UINT8 --input_type=QUANTIZED_UINT8 --input_array=占位符 --output_array=final_result --input_shape=1,224,224,3 --mean_values=128 --std_values=128 --default_ranges_min=0 --default_ranges_max=6
我已经重现了您看到的错误,并且能够使用以下命令使其正常工作:
python tensorflow/tensorflow/examples/image_retraining/retrain.py \
--image_dir /tmp/flower_photos \
--learning_rate=0.001 \
--testing_percentage=20 \
--validation_percentage=20 \
--train_batch_size=32 \
--validation_batch_size=-1 \
--flip_left_right True \
--random_scale=30 \
--random_brightness=30 \
--eval_step_interval=100 \
--how_many_training_steps=200 \
--architecture mobilenet_1.0_224_quantized
和
bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=/tmp/output_graph.pb \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--output_file=/tmp/mobilenet_quantized_224.tflite \
--inference_type=QUANTIZED_UINT8 \
--input_type=QUANTIZED_UINT8 \
--input_array=Placeholder \
--output_array=final_result \
--input_shape=1,224,224,3 \
--mean_value=128 \
--std_value=128 \
--default_ranges_min=0 \
--default_ranges_max=6
让我知道这是否适合你。
重现方式:
使用命令重新训练移动网络:
python tensorflow/tensorflow/examples/image_retraining/retrain.py
—image_dir (data-pwd)
—learning_rate=0.001 —testing_percentage=20
—validation_percentage=20 —train_batch_size=32
—validation_batch_size=-1 —flip_left_right True
—random_scale=30 —random_brightness=30
—eval_step_interval=100 —how_many_training_steps=200
—architecture mobilenet_1.0_224_quantized —default_ranges_min=0
—default_ranges_max=6 —std_values=224
—mean_values=224
mean values
和 std_values
并没有什么区别 - 尝试了不同的组合。
然后我像这样转换生成的 .pb 文件:
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=(path)/output_graph.pb --input_format=TENSORFLOW_GRAPHDEF
--output_format=TFLITE
--output_file=./mobilenet_quantized_224.tflite --inference_type=QUANTIZED_UINT8
--input_type=QUANTIZED_UINT8 --input_array=Placeholder --output_array=final_result
--input_shape=1,224,224,3
--output_array=final_result --input_shape=1,224,224,3
然后我用生成的模型替换了两个库存应用程序:iOS 简单和 Android 相机示例应用程序中的 tflite 模型。这会导致相同的错误:
错误:
Android:
Can not allocate memory for the given inputs:
tensorflow/contrib/lite/kernels/kernel_util.cc:34
input_product_scale < output_scale was not true.
iOS:
/Library/Developer/CoreSimulator/Devices/10888914-22EB-4CA7-B019-F95D5A8A6F5C/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
nnapi error: unable to open library libneuralnetworks.so
Loaded model resolved reportertensorflow/contrib/lite/kernels
/kernel_util.cc:34 input_product_scale < output_scale was not
true.Failed to allocate tensors!(lldb)
问题:
如何解决...错误? :)
在我添加赏金时进行编辑: 目标是获得有关如何重新训练模型并获得它的解释 运行 tensorflow lite。我知道这是非常新的,但我 运行 经常遇到文档错误。
下面的方法不适合你吗?
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=(路径)/output_graph.pb --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file=./mobilenet_quantized_224.tflite --inference_type=QUANTIZED_UINT8 --input_type=QUANTIZED_UINT8 --input_array=占位符 --output_array=final_result --input_shape=1,224,224,3 --mean_values=128 --std_values=128 --default_ranges_min=0 --default_ranges_max=6
我已经重现了您看到的错误,并且能够使用以下命令使其正常工作:
python tensorflow/tensorflow/examples/image_retraining/retrain.py \
--image_dir /tmp/flower_photos \
--learning_rate=0.001 \
--testing_percentage=20 \
--validation_percentage=20 \
--train_batch_size=32 \
--validation_batch_size=-1 \
--flip_left_right True \
--random_scale=30 \
--random_brightness=30 \
--eval_step_interval=100 \
--how_many_training_steps=200 \
--architecture mobilenet_1.0_224_quantized
和
bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=/tmp/output_graph.pb \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--output_file=/tmp/mobilenet_quantized_224.tflite \
--inference_type=QUANTIZED_UINT8 \
--input_type=QUANTIZED_UINT8 \
--input_array=Placeholder \
--output_array=final_result \
--input_shape=1,224,224,3 \
--mean_value=128 \
--std_value=128 \
--default_ranges_min=0 \
--default_ranges_max=6
让我知道这是否适合你。