我在自己的训练集上训练过R-FCN模型。现在,我想将* .pb格式的冻结推理图转换为* .tflite格式,以便在Android手机上使用。
训练结束后,我使用以下命令导出冻结的推理图:
python3 export_inference_graph.py
--pipeline_config_path="training/ckpt/rfcn-69/pipeline.config"
--trained_checkpoint_prefix="training/ckpt/rfcn-69/model.ckpt-300000"
--output_directory="training/ckpt/rfcn-69/"
之后我运行transform_graph工具来量化图形。我注意到,无论是否运行transform_graph都没关系。最后,我对两个图表都得到了相同的错误。
bazel run tensorflow/tools/graph_transforms/transform_graph --
--in_graph="/git/bda/frozen_graphs/rfcn-69/frozen_inference_graph.pb"
--out_graph="/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb"
--inputs=image_tensor
--outputs="num_detections,detection_boxes,detection_scores,detection_classes"
--transforms='fold_old_batch_norms quantize_weights strip_unused_nodes sort_by_execution_order obfuscate_names merge_duplicate_nodes'
最后,我尝试使用toco util将量化图转换为tflite图。
bazel run --config=opt tensorflow/contrib/lite/toco:toco --
--input_file=/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb
--output_file=/git/bda/frozen_graphs/out.tflite --inference_type=FLOAT
--input_shape=1,600,1024,3
--input_array=image_tensor
--output_arrays=num_detections,detection_boxes,detection_scores,detection_classes
但是,操作失败并出现以下错误。
2018-04-11 13:19:58.364591: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364606: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364656: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayReadV3
2018-04-11 13:19:58.364753: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364851: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364969: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.365001: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArraySizeV3
2018-04-11 13:19:58.365022: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.366115: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:20:00.620101: F tensorflow/contrib/lite/toco/tooling_util.cc:821] Check failed: d >= 1 (0 vs. 1)
我不知道可能是什么问题。任何帮助都将受到高度赞赏。
提前致谢。