(二) Ubuntu安装新版tensorflow以及目标检测API

https://github.com/tensorflow/models/blob/master/object_detection/g3doc/installation.md#installation 安装指南
Installation
Dependencies
Tensorflow Object Detection API depends on the following libraries:
  • Protobuf 2.6
  • Pillow 1.0
  • lxml
  • tf Slim (which is included in the "tensorflow/models" checkout)
  • Jupyter notebook
  • Matplotlib
  • Tensorflow
For detailed steps to install Tensorflow , follow the  Tensorflow installation instructions . A typically user can install Tensorflow using one of the following commands:

# For CPU
pip install tensorflow


卸载了之前的版本tensorflow0.8.0
sudo pip uninstall tensorflow
使用上面这句话,直接就安装了新版本tensorflow1.3.0
安装后tensorflow再python2.7的包里面

# For GPU
pip install tensorflow-gpu


The remaining libraries can be installed on Ubuntu 16.04 using via apt-get: 通过apt-get安装

sudo apt-get install protobuf-compiler python-pil python-lxml
sudo pip install jupytersudo
pip install matplotlib

Alternatively, users can install dependencies using pip:或者用pip安装

sudo pip install pillowsudo
pip install lxmlsudo
pip install jupytersudo
pip install matplotlib


这里没提要下载这个models文件夹,但是需要单独下载这个文件夹,
新建一个文件夹叫tensorflow,下载到这里面。
下载tensorflow/models的代码:

git clone https://github.com/tensorflow/models.git



Protobuf Compilation
安装或升级protoc
首先需要安装或升级protoc,不然在后面会无法编译。
安装/升级的方法是去protobuf的Release界面: google/protobuf ,下载对应的已经编译好的protoc。
比如我是64位的ubuntu,那么就下载protoc-3.3.0-linux-x86_64.zip。下载解压后会有一个protoc二进制文件,覆盖到对应目录即可
(如果不放心的可以用cp /usr/bin/protoc ~/protoc_bak先备份一下): (已经备份 在主文件夹中)

sudo cp bin/protoc /usr/bin/protoc


The Tensorflow Object Detection API uses Protobufs to configure model and training parameters. Before the framework can be used, the Protobuf libraries must be compiled. This should be done by running the following command from the tensorflow/models directory :
Tensorflow对象检测API使用Protobufs来配置模型和训练参数。 在使用框架之前, 必须编译Protobuf库 。 这应该通过从tensorflow / models目录运行以下命令来完成: 要进入到models里面后运行这句话

# From tensorflow/models/
protoc object_detection/protos/*.proto --python_out=.



Add Libraries to PYTHONPATH
When running locally, the tensorflow/models/ and slim directories should be appended to PYTHONPATH. This can be done by running the following from tensorflow/models/:
当在本地运行时, tensorflow / models /和slim目录应该附加到PYTHONPATH 。 这可以通过从tensorflow / models /运行以下来完成:

# From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

Note: This command needs to run from every new terminal you start. If you wish to avoid running this manually, you can add it as a new line to the end of your ~/.bashrc file. 注意:此命令需要从您启动的每个新终端运行, 只适用于当前终端 。 如果您想避免手动运行,可以将其作为新行添加到〜/ .bashrc文件的末尾。
在用户主目录下有一个 .bashrc 隐藏文件,可以在此文件中加入 PATH 的设置如下:
$ gedit ~/.bashrc
加入:
export PATH=<你的要加入的路径>:$PATH
如果要加入多个路径,只要:
export PATH=<你要加入的路径1>:<你要加入的路径2>: ...... :$PATH
当中每个路径要以冒号分隔。
这样每次登录都会生效
添加PYTHONPATH的方法也是这样,在.bashrc中添加
export PYTHONPATH=/home/zhao/setup/caffe-master/ Python :/home/zhao/setup/mypy:$PYTHONPATH 
保存后在终端输入 $ source ~/.bashrc 使环境变量立即生效
export PYTHONPATH=$PYTHONPATH:/media/room/0CA414560CA41456/tensorflow/models:/media/room/0CA414560CA41456/tensorflow/models/slim



Testing the Installation
You can test that you have correctly installed the Tensorflow Object Detection API by running the following command:
python object_detection/builders/model_builder_test.py


如果报错:就是slim那块没有配置好!

Tensorflow Object Detection API 目标检测API 就ok了!!!

你可能感兴趣的:(Tensorflow,目标检测API)