版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shiheyingzhe/article/details/86663889
压缩模型需要从源代码编译,需要安装bazel
官网的安装方式:https://docs.bazel.build/versions/master/install-ubuntu.html
这里采用Installing using binary installer方式,即使用sh文件安装
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
wget https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-installer-linux-x86_64.sh
sudo chmod +x bazel-0.21.0-installer-linux-x86_64.sh
./bazel-0.21.0-installer-linux-x86_64.sh --user
设置环境变量:
sudo gedit ~/.bashrc,最后一行加上
export PATH="$PATH:$HOME/bin"
然后使之生效:source ~/.bashrc
下载最新的TensorFlow库
git clone https://github.com/tensorflow/tensorflow.git
cd ./tensorflow
编译graph_transforms模块,需要等待一段时间,编译很耗费CPU资源和时间
bazel build tensorflow/tools/graph_transforms:transform_graph
查看冻结模型pb的总结
bazel-bin/tensorflow/tools/graph_transforms/summarize_graph --in_graph=/home/zj/frozen_inference_graph.pb