Raspberry Pi上的Tensorflow Lite-安装
在我目前的项目中,我使用机器学习的树莓Pi传感器融合。自从我听说Tensorflow Lite发布以来,我非常有兴趣在平台上部署并使用它来运行Lite模型 Tensorflow网站上有关于Android和iOS的提示,但我找不到任何关于其他平台的提示。是否有(WIP)安装/编译指南将TF Lite引入RaspiRaspberry Pi上的Tensorflow Lite-安装,tensorflow,raspberry-pi,tensorflow-lite,Tensorflow,Raspberry Pi,Tensorflow Lite,在我目前的项目中,我使用机器学习的树莓Pi传感器融合。自从我听说Tensorflow Lite发布以来,我非常有兴趣在平台上部署并使用它来运行Lite模型 Tensorflow网站上有关于Android和iOS的提示,但我找不到任何关于其他平台的提示。是否有(WIP)安装/编译指南将TF Lite引入Raspi TIA在TFLite文档中有一个关于树莓皮的非常小的部分。该部分链接到此GitHub文档,并提供在Raspberry PI-上构建TFLite的说明 目前还没有官方的演示应用程序,但第一
TIA在TFLite文档中有一个关于树莓皮的非常小的部分。该部分链接到此GitHub文档,并提供在Raspberry PI-上构建TFLite的说明
目前还没有官方的演示应用程序,但第一个地点说,一个是计划中的。准备好后,它可能会在同一位置共享(这是Android和iOS演示应用程序的描述)。@all,如果您仍在尝试让tensorflow lite在Raspberry Pi 3上运行,我的“pull请求”可能会有用。请看 按照这些步骤,可以在Raspberry Pi 3上运行两个应用程序(label_image和camera) 最好的
--Jim您可以使用“PIP install TensorFlow”在Raspberry pi上安装TensorFlow PIP,但是,如果您只需要TFLite,您可以构建一个只有TFLite解释器的较小PIP(然后您可以在另一台大机器上进行转换) 有关如何执行此操作的信息,请参见: 然后,你可以使用它。下面是一个您可以如何使用它的示例
将tflite_运行时作为tflr导入
解释器=tflr.lite.解释器(model\u path=“mobilenet\u float.tflite”)
explorer.allocate()
输入=解释器。获取输入详细信息()[0]
输出=解释器。获取输入详细信息()[0]
cap=cv2.视频捕获(0)#打开第0个网络摄像头
而1:
ret,frame=cap.read()
frame=cv2.CVT颜色(frame,cv2.COLOR_BGR2RGB)
frame=cv2.resize(frame,input.shape[2],input.shape[1])
frame=np.重塑(im,input.shape).astype(np.float32)/128.0-1.0
解释器。设置张量(输入[“索引”],帧)
invoke()解释器
标签=解释器。获取张量(输出[“索引”])
顶部标签索引=np.argmax(标签,轴=-1)
希望这能有所帮助。我建议接下来的链接:
# Initiate the interpreter
interpreter = tf.lite.Interpreter(PATH_TO_SAVED_TFLITE_MODEL)
# Allocate memory for tensors
interpreter.allocate_tensors()
# Get input and output tensors
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
# Add a batch dimension if needed (data_tensor - your data input)
input_data = tf.extend.dims(data_tensor, axis=0)
# Predict
interpreter.set_tensor(input_details[0]['index'], data_tensor)
interpreter.invoke()
# Obtain results
predictions = interpreter.get_tensor(output_details[0]['index'])
也许这会有帮助。构建总是会因为致命错误而停止。对于benchmark_model.o,配方在第112行失败。你运气好吗?