问题描述
我正在使用tensorflow对象检测api,使用来自tensorflow 动物园模范.
I am using tensorflow object-detection api for training a custom model using ssdlite_mobilenet_v2_coco_2018_05_09 from tensorflow model zoo.
我成功地训练了模型并使用本教程.
I successfully trained the model and test it out using a script provided in this tutorial.
这是问题所在,我需要一个 detect.tflite 才能在目标计算机(嵌入式系统)中使用它.但是,当我实际上用模型制作tflite时,它几乎不输出,而当它出现时,它的检测错误.要制作.tflite文件,我首先通过文档和一些Google搜索:
Here is the problem, I need a detect.tflite to use it in my target machine (an embedded system). But when I actually make a tflite out of my model, it outputs almost nothing and when it does, its a wrong detection. To make the .tflite file, I first used export_tflite_ssd_graph.py
and then toco
on the output with this command by following the doc and some google searches:
此外,当我使用ssd_mobilenet_v3_small_coco detect.tflite文件对其进行测试时,.tflite用于检测任务的代码也可以正常工作.
Also, the code I'm using for detection task from .tflite is working properly, as I tested it with ssd_mobilenet_v3_small_coco detect.tflite file.
推荐答案
问题出在toco
命令.我使用的某些文档已过时并误导了我. toco
已过时,我应该改用tflite_convert
工具.
The problem was with the toco
command. Some documents that I used were outdated and mislead me. toco
is deprecated and I should have used tflite_convert
tool instead.
这是我使用的完整命令(从您的培训目录中运行):
Here is the full command I used (run from your training directory):
我对ssdlite_mobilenet_v2_coco_2018_05_09模型进行了培训,并将其添加到我的.config文件末尾.
I did the training on ssdlite_mobilenet_v2_coco_2018_05_09 model and added this at the end of my .config file.
graph_rewriter {
quantization {
delay: 400
weight_bits: 8
activation_bits: 8
}
}
我也使用此命令在tflite_inference_graph目录中生成tflite_graph.pb:
Also I used this command to generate tflite_graph.pb in tflite_inference_graph directory:
注意:我想在嵌入式系统上使用量化模型.这就是我在配置文件中添加graph_rewriter并在tflite_convert命令中添加--inference_type = QUANTIZED_UINT8的原因.
Note: I wanted to use a quantized model on my embedded system. That is the reason I added graph_rewriter in the config file and --inference_type=QUANTIZED_UINT8 in my tflite_convert command.
这篇关于如何正确地将tflite_graph.pb转换为detect.tflite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!