yum install automake autoconf libtool libicu gcc-c++
####yum install bazel -y 这样安装版本过新会报错:
lease downgrade your bazel installation to version 0.26.1 or lower to build TensorFlow
yum -y install epel-release
yum -y install python-pip
git clone http://github.com/tensorflow/tensorflow
https://github.com/bazelbuild/bazel/releases/tag/0.26.1
去下载相关的版本的bazel
BAZEL_VERSION="0.26.1" # insert your desired version here, for example 0.26.0
$ wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh # if not on x86_64, change that too
$ chmod +x bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh # or the file you just downloaded
$ ./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
$ bazel version # this should now print the same as BAZEL_VERSION
参考 https://www.cnblogs.com/harrymore/p/10028489.html
不好用
bazel build -c opt --copt=-msse4.1 --copt=-msse4.2 //tensorflow/tools/pip_package:build_pip_package
https://www.dearcodes.com/index.php/archives/25/
pip install --upgrade pip
pip install numpy grpcio Keras-Applications Keras-Preprocessing h5py requests enum --trusted-host pypi.doubanio.com
import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(66)
b = tf.constant(88)
print(sess.run(a + b))
conda create -n bazelevn python=3
source activate bazelevn
cd tensorflow
./configure
全选no
pip install numpy
git submodule foreach git pull origin master
bazel build tensorflow/python/tools:freeze_graph
################## conda 环境:
conda update --all
conda create -n bazelenv python=3
source activate bazelenv
#conda deactivate
#conda remove bazelenv
git clone http://github.com/tensorflow/tensorflow
./configure
全选no
bazel build //tensorflow:libtensorflow.so //tensorflow/contrib/session_bundle:session_bundle
############ 测试一个tf生成模型,使用模型,再用调用so的过程使用模型的过程
conda create -n tfenv
conda install -n tfenv tensorflow
参考 https://blog.csdn.net/zmlovelx/article/details/80919193
创建模型:
saver_hello.py
import tensorflow as tf
if __name__ == '__main__':
hello = tf.Variable(tf.constant('Hello World', name = "hello"))
#init = tf.initialize_all_variables() #deprecated
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
saver = tf.train.Saver()
saver.save(sess, "./hello_model")
使用模型:
restore_hello.py
import tensorflow as tf
if __name__ == '__main__':
restore = tf.train.import_meta_graph("hello_model.meta")
sess = tf.Session()
restore.restore(sess, "hello_model")
print(sess.run(tf.get_default_graph().get_tensor_by_name("hello:0")))
验证
python saver_hello.py
生成 hello_model.meta 等文件
python restore_hello.py
main.cpp
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/core.hpp>
int main( int argc, char **argv )
{
if (argc != 2)
{
printf( "argc %d != 2\n", argc );
exit(-1);
}
cv::dnn::Net net = cv::dnn::readNetFromTensorflow(argv[1]);
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project( test )
#set(OpenCV_DIR /usr/local/Cellar/opencv@2/2.4.13.7_5)
set(OpenCV_DIR /usr/local/Cellar/opencv/4.1.1_2)
#INCLUDE_DIRECTORIES("${OpenCV_DIR}/include")
SET(CMAKE_CXX_FLAGS "-g -O3 -Ddarwin -std=c++11")
INCLUDE_DIRECTORIES("${OpenCV_DIR}/include/opencv4")
LINK_DIRECTORIES("${OpenCV_DIR}/lib")
add_executable(test main.cpp)
target_link_libraries(test opencv_core)
target_link_libraries(test opencv_highgui)
target_link_libraries(test opencv_ml)
target_link_libraries(test opencv_dnn)
注意需要opencv_dnn , 还有include的路径不太一样
mkdir build
cd build
cmake ..
make
./test ../hello_model.index
############## 需要opencv
brew search opencv
brew install opencv
#这个里面含dnn
普通的用下面这个
brew install opencv@2
#For compilers to find openblas you may need to set:
# export LDFLAGS="-L/usr/local/opt/openblas/lib"
# export CPPFLAGS="-I/usr/local/opt/openblas/include"
#For pkg-config to find openblas you may need to set:
# export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
假设安装到了/usr/local/Cellar/opencv@2/2.4.13.7_5
opencv的helloworld:
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main(int argc, char** argv) {
//create a gui window:
namedWindow("Output",1);
//initialize a 120X350 matrix of black pixels:
Mat output = Mat::zeros( 120, 350, CV_8UC3 );
//write text on the matrix:
putText(output,
"Hello World :)",
cvPoint(15,70),
FONT_HERSHEY_PLAIN,
3,
cvScalar(0,255,0),
4);
//display the image:
imshow("Output", output);
//wait for the user to press any key:
waitKey(0);
return 0;
}
g++ -I/usr/local/Cellar/opencv@2/2.4.13.7_5/include -L /usr/local/Cellar/opencv@2/2.4.13.7_5/lib -lopencv_core -lopencv_highgui -lopencv_ml main.cpp
如果用cmake,
CMakeLists.txt为
cmake_minimum_required(VERSION 2.8)
project( test )
set(OpenCV_DIR /usr/local/Cellar/opencv@2/2.4.13.7_5)
INCLUDE_DIRECTORIES("${OpenCV_DIR}/include")
LINK_DIRECTORIES("${OpenCV_DIR}/lib")
add_executable(test main.cpp)
target_link_libraries(test opencv_core)
target_link_libraries(test opencv_highgui)
target_link_libraries(test opencv_ml)
注意最重要的三个库 opencv_core opencv_highgui opencv_ml
mkdir build
cd build
cmake ..
make
./test 验证
#####################
分享到:
相关推荐
bert-base-chinese-tf_model.h5
MobileNet_v1_1.0.pb使用tf slim训练的mobilenet_v1_1.0; mobilenet_v1.tflite将MobileNet_v1_1.0.pb转成mobilenet_v1.tflite未量化; mobilenet_v1_kmodel_v4.kmodel 即通过NNCase v0.2.0 Beta2工具编译...
tf-hello-world 遵循此博客文章的Terraform快速入门: : Terraform代码成功执行以下操作: 部署一台服务器部署单个Web服务器部署可配置的Web服务器部署Web服务器集群部署负载均衡器
在各类JSP应用程序中,JSP+JavaBean的组合成为了一种事实上最常见的JSP程序的标准,本章就来讲解JSP与JavaBean的结合模型。
包含了两个Tflite模型:人与花
针对k210或者其他AI嵌入式设备提供转化代码,支持训练、优化、转化相关内容,提供端到端的模型训练和转换。
1、保存模型:model.save_weights(‘./model.h5’) 2、脚本重启 3、加载模型:model.load_weights(‘./model.h5’) 4、模型报错:ValueError: You are trying to load a weight file containing 12 layers into a ...
介绍如何使用`TF Lite model maker`库创建TensorFlow Lite模型。我们将在自定义数据集上微调一个预训练的图像分类模型,并进一步探索Tensorflow Lite支持的不同类型的模型优化技术,并将其导出到TF Lite模型。将创建...
tf_model_archive
TF卡测试工具TF card test tool,经过测试验证,具体请下载
查看你安装的tensorflow版本:import tensorflow as tf我这里是tensorflow1.4,所以切换分之并运行:因为demo需要先下
JQ8900-TF语音模块使用说明书串口测试程序等资料包:‘ JQ8900-TF语音模块使用说明书V2.1.pdf MP3格式转换器 串口测试程序 串口调试软件.exe 播放模式-配置工具.exe 测试音频 语音合成软件
Api-hello_tf_c_api.zip,神经网络tensorflow capiExample tensorflow c api,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库通信。通过提取实现并将数据放弃到对象中,...
Micro SD、Micro SD - duplicate、MICRO SIM、SD、SD 6IN1、SD CARD、SD CARD 全高、SD CARD 半高、SD-1、SD-2、SD-3、SD/MMC、SDCARD-M、SDCARD_A、SDCARD_B、SDPCB、SD_1、TF、TF-1、TF-2、TF-3、TF-4、TF-CARD、...
官方例子,深度学习专用,机器学习专用,代码简单,一看就会(dlcv benchmark model demo)
使用public文件夹 更改HTML 在模块系统之外添加资产 何时使用public文件夹 使用全局变量 添加引导程序使用自定义主题 增加流量 添加路由器 添加自定义环境变量 在HTML中引用环境变量 在Shell中添加临时环境变量 在....
TF卡收据手册,有TF卡各种参数,适合硬件设计参考。
倍福PLC的 modbus TCP server
SD、TF卡座封装大全2D3D三维视图PCB封装库AD库(28个合集) 1-MARK Micro SD MICRO SIM SD SD_1 SD 6IN1 SD CARD SD CARD 半高 SD CARD 全高 SD-1 SD-2 SD-3 SD-4 SD/MMC SDCARD_A SDCARD_A - duplicate SDCARD_B ...
bvlc_alexnet.caffemodel,