Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何正确地将tflite_graph.pb转换为detect.tflite_Python_Tensorflow_Object Detection Api_Tensorflow Lite - Fatal编程技术网

Python 如何正确地将tflite_graph.pb转换为detect.tflite

Python 如何正确地将tflite_graph.pb转换为detect.tflite,python,tensorflow,object-detection-api,tensorflow-lite,Python,Tensorflow,Object Detection Api,Tensorflow Lite,我正在使用tensorflow对象检测api,使用tensorflow提供的ssdlite_mobilenet_v2_coco_2018_05_09来培训定制模型 我成功地训练了模型,并使用中提供的脚本进行了测试 问题是,我需要一个detect.tflite在我的目标机器嵌入式系统中使用它。但是,当我从我的模型中实际生成一个tflite时,它几乎什么也不输出,当它生成时,它是一个错误的检测。为了生成.tflite文件,我首先使用export\u tflite\u ssd\u graph.py,然

我正在使用tensorflow对象检测api,使用tensorflow提供的ssdlite_mobilenet_v2_coco_2018_05_09来培训定制模型

我成功地训练了模型,并使用中提供的脚本进行了测试

问题是,我需要一个detect.tflite在我的目标机器嵌入式系统中使用它。但是,当我从我的模型中实际生成一个tflite时,它几乎什么也不输出,当它生成时,它是一个错误的检测。为了生成.tflite文件,我首先使用export\u tflite\u ssd\u graph.py,然后通过以下和一些google搜索对输出使用toco命令:

toco-graph\u def\u file=$OUTPUT\u DIR/tflite\u graph.pb-OUTPUT\u file=$OUTPUT\u DIR/detect.tflite-input\u shapes=1300300,3-input\u array=normalized\u input\u image\u tensor-OUTPUT\u array='tflite\u Detection\u PostProcess','tflite\u Detection\u PostProcess:1','tflite\u Detection\u PostProcess:2','tflite\u Detection\u PostProcess:3'-允许自定义操作

另外,我用于.tflite中检测任务的代码工作正常,因为我使用ssd\u mobilenet\u v3\u small\u coco detect.tflite文件对其进行了测试。

问题在于toco命令。我使用的一些文件已经过时,误导了我。toco已被弃用,我应该改用tflite\u转换工具

以下是我从您的培训目录中运行的完整命令:

tflite\u convert-图形定义文件tflite\u推理图/tflite\u graph.pb -输出文件=./detect.tflite-output\u format=tflite-input\u shapes=1300300,3-input\u数组=标准化的输入图像张量-output\u数组='tflite\u Detection\u PostProcess','tflite\u Detection\u PostProcess:1','tflite\u Detection\u PostProcess:2','tflite\u Detection\u PostProcess:3' -推断类型=量化范围8-平均值=128-标准值=127-更改输入范围=假-允许自定义操作

我在ssdlite_mobilenet_v2_coco_2018_05_09型号上进行了培训,并将其添加到了我的.config文件末尾

 graph_rewriter {
  quantization {
    delay: 400
    weight_bits: 8
    activation_bits: 8
  }
}
我还使用此命令在tflite\u expression\u graph目录中生成tflite\u graph.pb:

python export\u tflite\u ssd\u graph.py-pipeline\u config\u path 2020-05-17\u train\u ssdlite\u v2/ssd\u mobilenet\u v2\u coco.config-train\u checkpoint\u prefix 2020-05-17\u train\u ssdlite\u v2/train/model.ckpt-1146-输出目录2020-05-17\u train\u ssdlite\u v2/tflite\u推断\u图-添加\u后处理\u op=true

注:我想在我的嵌入式系统上使用量化模型。这就是为什么我在配置文件中添加了graph\u rewriter,并在tflite\u convert命令中添加了-interference\u type=QUANTIZED\u UINT8