【问题标题】:Quantizing object detection model量化目标检测模型
【发布时间】:2020-09-07 04:53:43
【问题描述】:
[2]  frozen_graph_file = # path to frozen graph (.pb file)
[3]  input_arrays = ["normalized_input_image_tensor"]
[4]  output_arrays = ['TFLite_Detection_PostProcess',
[5]            'TFLite_Detection_PostProcess:1',
[6]            'TFLite_Detection_PostProcess:2',
[7]            'TFLite_Detection_PostProcess:3']
[8]  input_shapes = {"normalized_input_image_tensor" : [1, 300, 300, 3]}
[9]
[10] converter = tf.lite.TFLiteConverter.from_frozen_graph(frozen_graph_file,
[11]                                                  input_arrays=input_arrays,
[12]                                                  output_arrays=output_arrays,
[13]                                                  input_shapes=input_shapes)
[14] converter.allow_custom_ops = True
[15] converter.optimizations = [tf.lite.Optimize.DEFAULT]
[16] tflite_quant_model = converter.convert()
[17] with open(tflite_model_quant_file, "wb") as tflite_file:
[18]     tflite_file.write(tflite_model_quant)

在量化模型时,我们通常为模型提供一些校准数据以识别激活范围,从而定义尺度和零点。这是为张量量化完成的。物体检测边界框坐标的量化值是如何获得的?它是否遵循相同的时尚? 在 Tensorflow 中,它们为无法以常规方式量化的操作提供自定义操作。我在哪里可以获得它们的详细实现,尤其是 TFLite_Detection_PostProcess?

【问题讨论】:

    标签: tensorflow object-detection tensorflow-lite quantization


    【解决方案1】:

    TFLite_Detection_PostProcess 的实现在https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/detection_postprocess.cc

    不管量化如何,TFLite_Detection_PostProcess 的输出总是float,所以我认为你不需要在这里关心它。

    【讨论】:

      猜你喜欢
      • 2021-05-05
      • 1970-01-01
      • 2020-04-28
      • 2020-06-01
      • 2020-10-17
      • 2018-01-09
      • 1970-01-01
      • 2022-06-20
      • 2022-08-08
      相关资源
      最近更新 更多