Tflite在python解释器和iOS中提供不同的准确性/行为

时间:2019-05-27 06:43:44

标签: python ios swift numpy tensorflow

我使用培训和服务实时移动物体检测器文章link自定义训练了物体检测模型。经过训练并将模型转换为tflite之后,我使用Python解释器测试了模型,然后通过遵循 github tflite iOS示例 link将其与iOS集成。该模型在python解释器上运行良好,但通过检测错误的对象和较低的置信度得分,在iOS中表现出完全不同的行为。

我尝试了几种模型,其中包括:

  1. ssd_mobilenet_v1_quantized_coco
  2. ssd_mobilenet_v2_quantized_coco

默认的tflite模型 detect.tflite provided in iOS github exmaple在iOS以及python解释器中均有效,而自定义模型则无效。

供参考的python解释器代码

import tensorflow as tf

# Load TFLite model and allocate tensors.
interpreter = tf.contrib.lite.Interpreter(model_path="converted_model.tflite")
interpreter.allocate_tensors()

# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

# Test model on random input data.
input_shape = input_details[0]['shape']
# change the following line to feed into your own data.
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)

interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)

0 个答案:

没有答案