我的 mobilenetV2 SSD 型号遇到了问题。我使用此处详述的步骤对其进行了转换,但我tflite_convert
在相关步骤中使用了 CLI 工具。
这工作正常,我能够执行推理,但输出大小不是我所期望的。
下面的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 个盒子。
有没有办法改变输出张量的大小?在转换或运行时?
我在经典 tensorflow 中的张量输出详细信息下方添加:
[<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 个或更少的盒子......
对此给予任何启示将不胜感激。
如果已经有人问过类似的问题,但我显然没有找到,请原谅。谢谢。
重新阅读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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句