【发布时间】:2019-02-25 10:26:00
【问题描述】:
我的 mobilenetV2 SSD 型号遇到问题。
我使用详细的步骤 here 对其进行了转换,但我使用 CLI 工具 tflite_convert 进行相关步骤。
这很好,我可以执行推理,但输出大小不是我预期的。
以下python代码行
interpreter.get_output_details()
告诉我要取回 10 个检测框:
[{'shape': array([ 1, 10, 4], dtype=int32), 'index': 252, 'name': 'TFLite_Detection_PostProcess', 'quantization': (0.0, 0), 'dtype': <class 'numpy.float32'>}, {'shape': array([ 1, 10], dtype=int32), 'index': 253, 'name': 'TFLite_Detection_PostProcess:1', 'quantization': (0.0, 0), 'dtype': <class 'numpy.float32'>}, {'shape': array([ 1, 10], dtype=int32), 'index': 254, 'name': 'TFLite_Detection_PostProcess:2', 'quantization': (0.0, 0), 'dtype': <class 'numpy.float32'>}, {'shape': array([1], dtype=int32), 'index': 255, 'name': 'TFLite_Detection_PostProcess:3', 'quantization': (0.0, 0), 'dtype': <class 'numpy.float32'>}]
到目前为止一切顺利,但在我的 pipeline.config 文件中,我指定了以下 post_processing 设置
post_processing {
batch_non_max_suppression {
score_threshold: 9.99999993922529e-09
iou_threshold: 0.6000000238418579
max_detections_per_class: 100
max_total_detections: 100
}
score_converter: SIGMOID
}
所以我希望输出的检测数为 100,因为在经典 tensorflow 中运行相同的模型会给我 100 个框。
有没有办法改变输出张量的大小?是在转化时还是在运行时?
我在经典张量流中的张量输出细节下面添加:
[<tf.Tensor 'prefix/detection_boxes:0' shape=<unknown> dtype=float32>, <tf.Tensor 'prefix/detection_scores:0' shape=<unknown> dtype=float32>, <tf.Tensor 'prefix/detection_classes:0' shape=<unknown> dtype=float32>, <tf.Tensor 'prefix/num_detections:0' shape=<unknown> dtype=float32>]
形状未知的地方,这是有道理的,因为我们可以有 100 个或更少的盒子......
我们将不胜感激。
如果有人问过类似的问题,但我显然没有找到,请原谅。谢谢。
【问题讨论】:
标签: python python-3.x tensorflow tensorflow-lite