【发布时间】:2021-09-28 05:53:47
【问题描述】:
我已经使用 tflite 模型生成器训练了跌倒和不跌倒的人检测模型,并且我在训练时对其进行了测试,但我想通过加载 tflite 文件并仅提供一张图像来进行测试。
【问题讨论】:
标签: python tensorflow tensorflow-lite
我已经使用 tflite 模型生成器训练了跌倒和不跌倒的人检测模型,并且我在训练时对其进行了测试,但我想通过加载 tflite 文件并仅提供一张图像来进行测试。
【问题讨论】:
标签: python tensorflow tensorflow-lite
This page 有关于如何使用 python 加载 TFLite 模型的说明:
import numpy as np
import tensorflow as tf
# Load the TFLite model and allocate tensors.
interpreter = tf.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 the model on random input data.
input_shape = input_details[0]['shape']
input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
# The function `get_tensor()` returns a copy of the tensor data.
# Use `tensor()` in order to get a pointer to the tensor.
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)
用您的输入图像替换input_data。
【讨论】: