使用toco将frozen_pb文件转换为tflite文件时出错

时间:2018-02-16 15:45:32

标签: python tensorflow machine-learning deep-learning tensorflow-lite

我使用mobileNet预训练模型进行对象检测。我拥有frozen_graph文件,我使用工具知道input_arrays和output_arrays。这是我的命令:

bazel-bin/tensorflow/contrib/lite/toco/toco \
  --input_file=$(pwd)/mobilenet_v1_1.0_224/frozen_graph.pb \
  --input_format=TENSORFLOW_GRAPHDEF  --output_format=TFLITE \
  --output_file=/tmp/mobilenet_v1_1.0_224.tflite --inference_type=FLOAT \
  --input_type=FLOAT --input_arrays=image_tensor \
  --output_arrays=detection_boxes,detection_scores,detection_classes,num_detections  --input_shapes=1,224,224,3

当我运行推荐时,会出现以下消息:

2018-02-16 19:44:08.718034: W 
tensorflow/contrib/lite/toco/toco_cmdline_flags.cc:178] --input_type 
is deprecated. It was an ambiguous flag that set both --
input_data_types and --inference_input_type. If you are trying to 
complement the input file with information about the type of input 
arrays, use --input_data_type. If you are trying to control the 
quantization/dequantization of real-numbers input arrays in the 
output file, use --inference_input_type.
2018-02-16 19:44:08.856935: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.857029: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayScatterV3
2018-02-16 19:44:08.857055: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.857079: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857099: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857143: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857162: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: LoopCond
2018-02-16 19:44:08.857238: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayReadV3
2018-02-16 19:44:08.857269: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857287: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857339: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayWriteV3
2018-02-16 19:44:08.857357: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.857388: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exit
2018-02-16 19:44:08.857400: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArraySizeV3
2018-02-16 19:44:08.857428: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayGatherV3
2018-02-16 19:44:08.857524: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: LogicalAnd
2018-02-16 19:44:08.897050: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Equal
2018-02-16 19:44:08.898806: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] 
Convertingunsupported operation: Equal
2018-02-16 19:44:08.899023: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.899129: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.899194: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exp
2018-02-16 19:44:08.899218: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exp
2018-02-16 19:44:08.899485: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899511: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899529: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899632: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayScatterV3
2018-02-16 19:44:08.899726: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayScatterV3
2018-02-16 19:44:08.899831: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayScatterV3
2018-02-16 19:44:08.899864: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899883: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899932: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899969: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayV3
2018-02-16 19:44:08.899997: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900021: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900044: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900084: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900105: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900195: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900216: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: LoopCond
2018-02-16 19:44:08.900276: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayReadV3
2018-02-16 19:44:08.900296: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900313: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900327: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayReadV3
2018-02-16 19:44:08.900342: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900354: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900371: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayReadV3
2018-02-16 19:44:08.900388: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900405: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900548: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Equal
2018-02-16 19:44:08.900577: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.900660: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.900746: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.900786: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.900903: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.901007: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting  
unsupported operation: NonMaxSuppressionV2
2018-02-16 19:44:08.901039: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: ZerosLike
2018-02-16 19:44:08.901120: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.901214: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.901336: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.901447: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: NonMaxSuppressionV2
2018-02-16 19:44:08.901485: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: ZerosLike
2018-02-16 19:44:08.901568: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.901651: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Unpack
2018-02-16 19:44:08.901780: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Where
2018-02-16 19:44:08.901891: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: NonMaxSuppressionV2
2018-02-16 19:44:08.901926: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: ZerosLike
2018-02-16 19:44:08.902033: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Size
2018-02-16 19:44:08.902053: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Equal
2018-02-16 19:44:08.902096: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TopKV2
2018-02-16 19:44:08.902883: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayWriteV3
2018-02-16 19:44:08.902909: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.902936: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayWriteV3
2018-02-16 19:44:08.902960: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.902989: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayWriteV3
2018-02-16 19:44:08.903013: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.903037: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayWriteV3
2018-02-16 19:44:08.903061: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Enter
2018-02-16 19:44:08.903117: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exit
2018-02-16 19:44:08.903135: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exit
2018-02-16 19:44:08.903150: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exit
2018-02-16 19:44:08.903165: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: Exit
2018-02-16 19:44:08.903187: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArraySizeV3
2018-02-16 19:44:08.903235: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayGatherV3
2018-02-16 19:44:08.903286: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArraySizeV3
2018-02-16 19:44:08.903352: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayGatherV3
2018-02-16 19:44:08.903400: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArraySizeV3
2018-02-16 19:44:08.903442: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayGatherV3
2018-02-16 19:44:08.903486: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArraySizeV3
2018-02-16 19:44:08.903547: I 
tensorflow/contrib/lite/toco/import_tensorflow.cc:1170] Converting 
unsupported operation: TensorArrayGatherV3
2018-02-16 19:44:08.932207: F 
tensorflow/contrib/lite/toco/tooling_util.cc:748] Check failed: d >= 
1 (0 vs. 1)
Abort trap: 6

最后的错误是:

Check failed: d >= 1 (0 vs. 1)
Abort trap: 6

我真的不知道错误是什么意思,你能给我一个帮助吗?感谢:)

2 个答案:

答案 0 :(得分:0)

简单的答案是TFLite还不支持所有TF操作。他们正在努力,但这就是为什么你看到所有“不支持的操作”错误。

如果您真的希望您的模型在等待TFLite支持时使用移动设备,请查看TensorFlow Mobile,这是一个不同的平台:https://www.tensorflow.org/mobile/

答案 1 :(得分:0)

由于不支持的操作,转换失败。 TensorFlow Lite仅支持以下操作的一部分:https://www.tensorflow.org/lite/guide/ops_compatibility

无论如何,您可以编写一个自定义操作以使其起作用: https://www.tensorflow.org/lite/guide/ops_custom