【问题标题】:mobilenetv2 tflite not expected output size with python3mobilenetv2 tflite 不是 python3 的预期输出大小
【发布时间】: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


    【解决方案1】:

    重读export_tflite_ssd_graph.py 脚本后,似乎有一个选项可以设置保留的最大检测数。

    将此设置为 100 解决了我的问题。心情不好。

    对于那些感兴趣的人,我从

    更改了我的导出命令
    python3 object_detection/export_tflite_ssd_graph.py \                                            
        --pipeline_config_path=$model_dir/pipeline.config \                                          
        --trained_checkpoint_prefix=$model_dir/model.ckpt \                                          
        --output_directory=$output_dir \                                                             
        --add_post_processing_op=true
    

    python3 object_detection/export_tflite_ssd_graph.py \                                            
        --pipeline_config_path=$model_dir/pipeline.config \                                          
        --trained_checkpoint_prefix=$model_dir/model.ckpt \                                          
        --output_directory=$output_dir \                                                             
        --add_post_processing_op=true \                                                              
        --max_detections=100
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多