通过第一章节,已经在Ubuntu16.04搭建好Tensorflow-GPU,下面我们来利用Google的TensorFlow Object Detection API实现对图片上物体的检测。
1、安装python相关依赖包
若是Python3,把pip换成pip3
pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib
2、到github下载Object Detection API模型
在终端执行:
git clone https://github.com/tensorflow/models.git
或者进入网站下载:https://github.com/tensorflow/models
3、下载protoc对Object Detection API模型进行编译
下载地址:https://github.com/protocolbuffers/protobuf/releases
推荐下载3.4.0版本,如下图:
解压后,进入该目录后执行:
sudo ./configure
sudo make check
sudo make install
查看protoc版本执行:
protoc --version
出现下图说明安装成功
接着进入models-master/research目录对模型进行编译,执行:
protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
4、测试
在终端执行:
jupyter notebook
会出现一个网站,如下图:
打开网址,便进入到网页版的jupyter
注意:在哪个目录打开jupyter notebook,则该目录为根目录,我的在models-master/research/object_detection目录打开。
然后找到object_detection_tutorial.ipynb文件,如下图:
点击run all
出现下面两张图片表示成功: