本次安装环境为 ubuntu-16.04.4系统,使用环境python3,因为之前已经安装了gpu版本的tensorflow和opencv等,所以不在安装.
1,在主目录下载api, git clone https://github.com/tensorflow/models.git(下载完后的路径为/home/user/models)
2,sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
3,pip3 install --user contextlib2(安装其他必要的软件)
4,安装cocoapi(参考我上一篇博客安装,很简单的,安装在主目录就行,安装后路径为/home/user/cocoapi)
5,进入/home/user/models/research/目录, 执行cp -r /home/user/cocoapi/PythonAPI/pycocotools ./ (拷贝/home/user/cocoapi/PythonAPI目录到第一步下载的/home/user/models/research/目录下)
6,在models/research/目录下执行protoc object_detection/protos/*.proto --python_out=.(如果直接安装编译报错,则通过如下方式安装:wget -O protobuf.zip https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip, unzip protobuf.zip, 在~/models/research/目录下执行./bin/protoc object_detection/protos/*.proto --python_out=.)
7,在models/research/目录下执行export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim,这是为了设置环境变量,每次重新打开一个窗口都要执行,如果嫌弃麻烦可以在这样:vi ~/.bashrc,在最后一行添加
export PYTHONPATH=$PYTHONPATH:/home/user/models/research:/home/user/models/research/slim
(/home/user/models/research为第一步下载的api目录)
8,在~/models/research/目录下执行python3 object_detection/builders/model_builder_test.py,测试是否安装成功(安装成功显示ok)
(如果报错ImportError: No module named nets,说明第7步没执行,或者执行有问题,记得第七部在/home/user/models/research下执行export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim即可)
至此环境搭建完毕...下一章教大家如何跑实例代码