TF Lite 对象检测仅返回 10 个检测 [英] TF Lite object detection only returning 10 detections

查看:36
本文介绍了TF Lite 对象检测仅返回 10 个检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在原生 Android 上使用带有 TensorFlow Lite 的自定义对象检测模型.在这一点上,我只检测到 2 个自定义对象.我正在使用 TensorFlow 对象检测 API,并且我有一个管道可以生成优化的 .tflite 文件.

I am using a custom object detection model with TensorFlow Lite on native Android. At this point I'm only detecting 2 custom objects. I am using the TensorFlow Object Detection API, and I have a pipeline in place that produces optimized .tflite files.

但是,在推理时,该模型最多只能返回 10 个单独的检测.根据 https://www.tensorflow.org/lite/models/object_detection/overview,这是意料之中的.问题是我的图像具有相对较大的对象密度.我需要能够在每个图像/推理调用中检测多达 30 个单独的对象.

However, at inference time, the model only returns up to 10 individual detections. According to https://www.tensorflow.org/lite/models/object_detection/overview, this is expected. The problem is that my images have a relatively large object density. I need to be able to detect up to 30 individual objects per image/inference call.

如果我将示例 Android 应用程序中的 NUM_DETECTIONS 从 TF 存储库从 10 更改为 20,由于形状不匹配,我会收到运行时异常.如何生成能够产生超过 10 个对象检测实例的 .tflite 文件?

If I change NUM_DETECTIONS in the sample Android app from the TF repo from 10 to, say, 20, I get a runtime exception due to shape mismatch. How can I produce .tflite files capable of yielding more than 10 object detection instances?

谢谢!

推荐答案

不幸的是,由于 TFLite 更喜欢静态形状的输入/输出,您需要重新导出具有所需输出数量的 TFLite SSD 图.说明位于此处.在调用 object_detection/export_tflite_ssd_graph.py 时,您需要传入参数 --max_detections=20.然后,您对 NUM_DETECTIONS 的更改应该会按预期工作.

Unfortunately, since TFLite prefers static-shaped Input/Outputs, you would need to re-export a TFLite SSD graph with the required number of outputs. Instructions are here. While invoking object_detection/export_tflite_ssd_graph.py, you would need to pass in the parameter --max_detections=20. Then, your change of NUM_DETECTIONS should work as expected.

这篇关于TF Lite 对象检测仅返回 10 个检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆