配置环境:win10,anaconda python 3.7, tensorflow 1.13.1
1.从https://github.com/tensorflow/models下载tensorflow object detection api文件"models-master.zip"并解压缩
2.从https://github.com/protocolbuffers/protobuf/releases下载"protoc-3.7.1-win64.zip"。解压缩后,将bin目录下的protoc.exe文件拷贝到C:\windows目录下。
3.打开系统cmd命令窗口,进入到models-master\research\object_detection\protos目录下,运行以下命令:
protoc --python_out=. .\object_detection\protos\anchor_generator.proto
protoc --python_out=. .\object_detection\protos\argmax_matcher.proto
protoc --python_out=. .\object_detection\protos\bipartite_matcher.proto
protoc --python_out=. .\object_detection\protos\box_coder.proto
protoc --python_out=. .\object_detection\protos\box_predictor.proto
protoc --python_out=. .\object_detection\protos\calibration.proto
protoc --python_out=. .\object_detection\protos\eval.proto
protoc --python_out=. .\object_detection\protos\faster_rcnn.proto
protoc --python_out=. .\object_detection\protos\faster_rcnn_box_coder.proto
protoc --python_out=. .\object_detection\protos\graph_rewriter.proto
protoc --python_out=. .\object_detection\protos\grid_anchor_generator.proto
protoc --python_out=. .\object_detection\protos\hyperparams.proto
protoc --python_out=. .\object_detection\protos\image_resizer.proto
protoc --python_out=. .\object_detection\protos\input_reader.proto
protoc --python_out=. .\object_detection\protos\losses.proto
protoc --python_out=. .\object_detection\protos\matcher.proto
protoc --python_out=. .\object_detection\protos\mean_stddev_box_coder.proto
protoc --python_out=. .\object_detection\protos\model.proto
protoc --python_out=. .\object_detection\protos\optimizer.proto
protoc --python_out=. .\object_detection\protos\pipeline.proto
得到以上各文件对应的*.py文件。
4. 打开anacodan prompt命令窗口,进入tensorflow环境,切换到models-master\research目录运行以下命令:
(tensorflow) F:\spidercode\five\models-master\research>python setup.py install
成功安装一系列文件后,在我的电脑上提示python-dateutil安装失败。运行以下命令安装python-dateutil:
(tensorflow) F:\spidercode\five\models-master\research>pip install python-dateutil
python-dateutil成功安装的同时,提示以下错误:
ERROR: matplotlib 3.1.0rc2 requires cycler>=0.10, which is not installed.
ERROR: matplotlib 3.1.0rc2 requires kiwisolver>=1.0.1, which is not installed.
ERROR: matplotlib 3.1.0rc2 requires pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1, which is not installed.
继续用以下命令,分别安装cycler, kiwisolver和pyparsing:
(tensorflow) F:\spidercode\five\models-master\research>pip install cycler
(tensorflow) F:\spidercode\five\models-master\research>pip install kiwisolver
(tensorflow) F:\spidercode\five\models-master\research>pip install pyparsing
5. 打开anacodan prompt命令窗口,进入tensorflow环境,切换到models-master\research\slim目录运行以下命令:
(tensorflow) F:\spidercode\five\models-master\research\slim>python setup.py install
安装一系列文件后,在我的电脑上提示以下错误:
error: could not create 'build': 当文件已存在时,无法创建该文件。
原因是slim文件夹下原本已经存在一个BUILD文件,所以无法创建build文件夹。将原来的BUILD文件移动到其他目录,再运行一次上述指令,即可成功安装。
6.运行以下命令测试tensorflow object detection api是否成功安装。
(tensorflow) F:\spidercode\five\models-master\research\object_detection\builders>python model_builder_test.py
出现以下类似信息,表明安装成功:
......s...
----------------------------------------------------------------------
Ran 16 tests in 0.101s