Tensorflow学习——配置Object Detection API

环境:Windows 10+TensorFlow-gpu-1.6.0

Object Detection链接:

https://github.com/tensorflow/models/tree/266c7b87251dac41e977f3167f39078954f609dd/research/object_detection

官方安装步骤:

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

简介:

    Object Detection API是一个构建在TensorFlow之上的开源框架,通过它可以构建,训练和部署对象检测模型,主要用于实现对目标对象的识别。

依赖:


一、安装Object Detection

    下载Object Detection源码,并解压,在系统路径中加入以下变量:

      ..\models-master

      ..\models-master\research

      ..\models-master\research\slim


二、通过pip安装依赖库

sudo pip install pillow
sudo pip install lxml
sudo pip install jupyter
sudo pip install matplotlib

若速度慢可以改用国内镜像,方法为:

命令+ -i +国内镜像

国内镜像:

清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/ 
豆瓣:http://pypi.douban.com/simple/


三、安装Protobuf

下载链接:https://github.com/google/protobuf/releases

建议不要下载最新版本(3.5.1)存在Bug,本文选择的是protoc-3.4.0-win32,下载解压后在系统路径中加入以下变量:

..\protoc-3.4.0-win32\bin

打开Windows PowerShell,cd到research目录下,运行以下命令。

# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.

若出现ImportError: No module named 'object_detection' 错误,可采取以下解决方法:

1、若直接采用pip安装则在以下路径建立.pth文件。

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\site-packages

然后添加下面内容:

..\models-master\research
..\models-master\research\slim

..\models-master\research\object_detection

2、若直接采用Anaconda安装则在以下路径建立.pth文件,然后同样处理。

..\Anaconda\Lib\site-packages


四、测试

打开Windows PowerShell,运行以下命令。

python object_detection/builders/model_builder_test.py

猜你喜欢

转载自blog.csdn.net/kalenee/article/details/80629211