【发布时间】:2019-09-01 04:33:39
【问题描述】:
尝试将保存的模型转换为 tflite。
型号名称:ssd_mobilenet_v1_ppn_coco https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
我尝试使用以下命令将模型转换为 tflite pb:
$tflite_convert --output_file=/tmp/dec.tflite
--saved_model_dir=/ppn/saved_model/
得到这个错误:
ValueError: None 仅在第一维中受支持。张量“image_tensor”的形状无效“[None, None, None, 3]”。
为了获取有关模型的更多信息,我使用 bazel 从源代码构建了 tensorflow 并运行以下命令:
$ bazel build tensorflow/tools/graph_transforms:summarize_graph
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --
in_graph=/Users/nadav/Desktop/tflite/
输出:
found 1 possible inputs: (name=image_tensor, type=uint8(4), shape=[?,?,?,3])
No variables spotted.
Found 4 possible outputs: (name=detection_boxes, op=Identity) (name=detection_scores, op=Identity) (name=num_detections, op=Identity) (name=detection_classes, op=Identity)
Found 2197495 (2.20M) const parameters, 0 (0) variable parameters, and 2089 control_edges
Op types used: 2325 Const, 549 GatherV2, 451 Minimum, 360 Maximum, 287 Reshape, 191 Sub, 183 Cast, 183 Greater, 180 Split, 180 Where, 119 StridedSlice, 116 Shape, 109 Pack, 101 ConcatV2, 99 Add, 96 Mul, 94 Unpack, 93 Slice, 92 ZerosLike, 91 Squeeze, 90 NonMaxSuppressionV2, 36 Identity, 30 Conv2D, 29 Switch, 29 Relu6, 26 Enter, 24 BiasAdd, 17 FusedBatchNorm, 14 Merge, 13 RealDiv, 12 Range, 11 DepthwiseConv2dNative, 11 TensorArrayV3, 8 ExpandDims, 8 NextIteration, 6 TensorArrayGatherV3, 6 TensorArrayWriteV3, 6 Exit, 6 TensorArraySizeV3, 5 TensorArrayReadV3, 5 MaxPool, 5 TensorArrayScatterV3, 4 Fill, 3 Assert, 3 Transpose, 2 Less, 2 Equal, 2 Exp, 2 LoopCond, 1 Tile, 1 TopKV2, 1 Placeholder, 1 ResizeBilinear, 1 Size, 1 Sigmoid
To use with tensorflow/tools/benchmark:benchmark_model try these arguments:
bazel run tensorflow/tools/benchmark:benchmark_model -- --graph=/ppn/frozen_inference_graph.pb
--show_flops
--input_layer=image_tensor
--input_layer_type=uint8
--input_layer_shape=-1,-1,-1,3
--output_layer=detection_boxes,detection_scores,num_detections,detection_classes
其他细节:
张量流版本:1.13.1 在 python 2.7 和 3.6.5 中运行它。
还尝试使用检查点 (ckpt) 文件而不是保存的模型,但它不起作用。
得到这个结果: ValueError: None 仅在第一维中受支持。张量“image_tensor”的形状无效“[None, None, None, 3]”。
预计: 两个文件:somefilename.pb somefilename.pbtxt
【问题讨论】:
标签: tensorflow-lite