1.安装所需的库文件:
pip install tensorflow(tensorflow的安装和验证可参考:https://www.tensorflow.org/install/)
pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib
2.安装protocbuf:
进入https://github.com/google/protobuf/releases
下载编译好的zip包:
下载后bin目录下会有一个protoc二进制文件,覆盖到对应目录:cp bin/protoc /usr/local/bin/protoc
3.下载modesl放置于tensorflow文件夹下:
/usr/local/lib/python3.6/site-packages/tensorflow/models
4.在tensorflow/models/research/文件夹下运行:
protoc object_detection/protos/*.proto --python_out=.
5.在tensorflow/models/research文件夹下运行:(注:每次打开新的终端都要运行,否则可能出现找不到modual报错,也可以用命令:echo export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim>>~/.bashrc,写入.bashrc,这样每次打开新的终端会自动加载这句命令)
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
6.测试安装,出现OK则没问题:
python object_detection/builders/model_builder_test.py
7.~/object_detection/文件夹下运行:jupyter-notebook
8.点击object_detection_tutorial.ipynb,等待一段时间可看到demo
9.该API能识别的模型有限,可通过如下做迁移学习,识别更多的物体:
https://pythonprogramming.net/custom-objects-tracking-tensorflow-object-detection-api-tutorial/?completed=/video-tensorflow-object-detection-api-tutorial/