Tensorflow_lite hello_world示例运行在Arduino/Devkit
原链接:https://www.youtube.com/watch?v=B_DcpRzkAiM视频中项目GitHub地址(不是Arduino项目):https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world在VS Code打开Arduino Libraries Man
原链接:
https://www.youtube.com/watch?v=B_DcpRzkAiM
视频中项目GitHub地址(如下) 并不是Arduino项目,因此,建议使用Arduino IDE 完成本项目,而不是VS Code。
Arduino IDE
The easiest way to install this library is through the Arduino's library manager. In the menus, go to Sketch->Include Library->Manage Libraries. This will pull the latest stable version.
GitHub
If you want to install an in-development version of this library, you can use the latest version directly from this GitHub repository. This requires you clone the repo into the folder that holds libraries for the Arduino IDE. The location for this folder varies by operating system, but typically it's in ~/Arduino/libraries
on Linux, ~/Documents/Arduino/libraries/
on MacOS, and My Documents\Arduino\Libraries
on Windows.
Once you're in that folder in the terminal, you can then grab the code using the git command line tool:
git clone https://github.com/tensorflow/tflite-micro-arduino-examples Arduino_TensorFlowLite
https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/hello_world
我安装的tensorflow lite 1.5版本,自动下载examples程序。采用如下图方式打开hello_world项目。
需要在.ino文件最上方添加宏定义。
#undef min
#undef max
还可以在arduino_output_handler.cpp中找到对应行修改如下代码
// The pin of the Arduino's built-in LED
int led = RGB_R;
//int led = LED_BUILTIN;
然后使用Arduino IDE的菜单“项目”——“上传”即可烧写到Arduino(或devkit)。
附加:
也可以在通过VS Code开发本项目,打开Arduino Libraries Manager后,搜索并安装tensorflowlite。Arduino examples程序,默认存放在这个目录(如果通过Arduino: Examples命令找不到):
C:\Users\Administrator\Documents\Arduino\libraries\Arduino_TensorFlowLite\examples
如视频中所讲,VSCode需要在.vscode目录的arduino.json中添加设置,其中port端口根据自己情况填写
{
"sketch": "hello_world.ino",
"board": "AZ3166:stm32f4:MXCHIP_AZ3166",
"configuration": "upload_method=OpenOCDMethod",
"output": "./build",
"port": "COM4"
}
如果编译报如下Problems
在 browse.path 中未找到包含文件。
原因是无法找到库文件所在路径,请把tflite库地址添加到c_cpp_properties.json配置文件includePath下。
C:/Administrator/Documents/Arduino/libraries
然后编译。
更多推荐
所有评论(0)