完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 donatello1996 于 2022-4-18 23:35 编辑 【飞凌嵌入式OKMX8MP-C 开发板试用体验】tensorflow-lite-2.6编译&运行label_image例程 凌厂家提供的使用手册中有提到基于tensorflow-lite的图像物品识别例程,名为label_iamge,这个例程是tensorflow-lite(下称tflite) github源码上已经有的例程,厂家所使用的tflite版本为r2.3,r表示release分支
下载之后,进入路径tensorflow-r2.6/tensorflow/lite/tools/make/,找到文件build_rpi_lib.sh,这个就是我们需要进行编译用的脚本,里面集成了make指令: 该文件会调用tensorflow/lite/tools/make/Makefile文件,若直接运行,会提示报错:
原因是该目录默认使用交叉编译方式进行编译,而如果下载到开发板上进行本地编译,需要修改编译器名称,在Makefile第310行到312行: 然后是将90行的neon-vfpv4编译选项去掉,将targets目录下的rpi_makefile.inc里面的neon-vfpv4编译选项和-march=armv7-a编译选项也去掉: 运行路径tensorflow-r2.6/tensorflow/lite/tools/make/下的downloads脚本:
这些downloads文件夹下的下载内容都是编译tensorflow-lite-2.6 label_image例程所必需的: 修改tensorflow/lite/tools/make/Makefile文件,添加label_image例程编译选项: 添加编译所需要的源文件: 修改tensorflow/lite/nnapi/sl/SupportLibrary.cc文件: /* Copyright 2021 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ // Changed when importing from AOSP #include "tensorflow/lite/nnapi/sl/include/SupportLibrary.h" // Changed when importing from AOSP #include #include #include #include #include #include "tensorflow/lite/minimal_logging.h" #include "tensorflow/lite/nnapi/NeuralNetworksTypes.h" namespace tflite { namespace nnapi { using tflite::TFLITE_LOG_ERROR; NnApiSupportLibrary::NnApiSupportLibrary(const NnApiSLDriverImplFL5& impl, void* libHandle) : NnApiSLDriverImplFL5(impl), libHandle(libHandle) { base.implFeatureLevel = ANEURALNETWORKS_FEATURE_LEVEL_5; } NnApiSupportLibrary::~NnApiSupportLibrary() { if (libHandle != nullptr) { dlclose(libHandle); libHandle = nullptr; } } std::unique_ptr const std::string& libName) { void* libHandle = dlopen(libName.c_str(), RTLD_LAZY | RTLD_LOCAL); if (libHandle == nullptr) { TFLITE_LOG(TFLITE_LOG_ERROR, "nnapi error: unable to open library %s: %s", libName.c_str(), dlerror()); return nullptr; } auto result = loadNnApiSupportLibrary(libHandle); if (!result) { dlclose(libHandle); } return result; } template std::unique_ptr return std::unique_ptr } std::unique_ptr void* libHandle) { NnApiSLDriverImpl* (*getSlDriverImpl)(); getSlDriverImpl = reinterpret_cast dlsym(libHandle, "ANeuralNetworks_getSLDriverImpl")); if (getSlDriverImpl == nullptr) { TFLITE_LOG(TFLITE_LOG_ERROR, "Failed to find ANeuralNetworks_getSLDriverImpl symbol"); return nullptr; } NnApiSLDriverImpl* impl = getSlDriverImpl(); if (impl == nullptr) { TFLITE_LOG(TFLITE_LOG_ERROR, "ANeuralNetworks_getSLDriverImpl returned nullptr"); return nullptr; } if (impl->implFeatureLevel < ANEURALNETWORKS_FEATURE_LEVEL_5) { int64_t impl_feature_level = impl->implFeatureLevel; TFLITE_LOG(TFLITE_LOG_ERROR, "Unsupported NnApiSLDriverImpl->implFeatureLevel: %" PRId64, impl_feature_level); return nullptr; } return make_unique *reinterpret_cast } } // namespace nnapi } // namespace tflite 然后运行tensorflow-r2.6/tensorflow/lite/tools/make/build_rpi_lib.sh进行编译,生成目标bin文件: 运行: |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
[技术] 【飞凌嵌入式OK3576-C开发板体验】llama2.c部署
5275 浏览 0 评论
6051 浏览 0 评论
【飞凌嵌入式OK3576-C开发板体验】ssh连接与文件传输
6219 浏览 0 评论
7616 浏览 0 评论
【飞凌嵌入式OK527N-C开发板体验】6.制作h264播放器
7163 浏览 0 评论
6742浏览 2评论
3206浏览 2评论
11043浏览 1评论
5154浏览 1评论
82620浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-8 08:24 , Processed in 0.694829 second(s), Total 58, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号