Tensorflow object detection API 搭建目标检测环境

Dependencies

Tensorflow Object Detection API depends on the following libraries:

  • Protobuf 3.0.0
  • Python-tk
  • Pillow 1.0
  • lxml
  • tf Slim (which is included in the "tensorflow/models/research/" checkout)
  • Jupyter notebook
  • Matplotlib
  • Tensorflow (>=1.9.0)
  • Cython
  • contextlib2
  • cocoapi

1.从github上clone tensorflow/models

方法一:安装git 在cmd使用 git clone http://github.com/tensorflow/models

下载速度非常慢,而且会经常性报错。

在下载过程中遇到的错误:

fatal: the remote end hung up unexpectedly (curl 56 OpenSSL SSL_read:SSL_ERROR_sysCALL)

在网上查阅到的解决方案:

git config http.sslVerify "false"

参考https://blog.csdn.net/m0_37052320/article/details/77799413?utm_source=blogxgwz1

https://blog.csdn.net/hoiyook/article/details/81870068

方法二:* 直接从github上clone然后解压缩

2.安装依赖库

pip install --user Cython
pip install --user contextlib2
pip install --user pillow
pip install --user lxml
pip install --user jupyter
pip install --user matplotlib

COCO API 安装:

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

Download the cocoapi and copy the pycocotools subfolder to the tensorflow/models/research directory if you are interested in using COCO evaluation metrics. The default metrics are based on those used in Pascal VOC evaluation. To use the COCO object detection metrics add metrics_set: "coco_detection_metrics" to the eval_config message in the config file. To use the COCO instance segmentation metrics add metrics_set: "coco_mask_metrics" to the eval_config message in the config file.

3.安装配置Protobuf

https://github.com/google/protobuf/releases 下载windows版本,解压后将 bin 文件夹下的 protoc.exe放到C:\Windows\System32下

在models-master\research\目录下打开cmd,输入:

protoc object_detection/protos/*.proto --python_out=.

将*.proto替换为/protos/目录下的文件名进行编译,编译完成后会生成对应的.py文件。

3.配置PYTHONPATH环境变量

在 ‘此电脑’-‘属性’- ‘高级系统设置’ -‘环境变量’-‘系统变量’ 中新建名为‘PYTHONPATH’的变量,将models/research/ 及 models/research/slim 两个文件夹的完整目录添加,分号隔开。

到此算全部安装完成。但是进行测试一直报错!

参考https://www.jianshu.com/p/1ed2d9ce6a88发现忘记了最重要的一步!安装

在models-master/research下打开cmd 运行

python setup.py install

运行测试命令:

python object_detection/builders/model_builder_test.py

仍然报错:

no models named 'nets'

删除slim目录下的BUILD文件重新安装,在models-master/research/slim目录下也运行

python setup.py install

再次测试,结果如下。

Tensorflow object detection API 搭建目标检测环境

此时才算安装成功。

 

参考:

https://blog.csdn.net/dy_guox/article/details/79081499

https://blog.csdn.net/xiaoxiao123jun/article/details/76605928?utm_source=blogxgwz0

https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

https://www.jianshu.com/p/1ed2d9ce6a88