[神经网络]一步一步使用Mobile-Net完成视觉识别(一)

1.环境配置

2.数据集获取

3.训练集获取

4.训练

5.调用测试训练结果

6.代码讲解

  本文是第一篇,环境配置篇。

先打开tensorflow object detection api 看看须要什么配置。python

固然,我写的教程不是很详细,详细的请看官方的教程:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.mdlinux

Tensorflow Object Detection API depends on the following libraries:git

  • 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

在安装以前,咱们先把这个object detection model 给git下来,在任意目录下,命令行输入如下命令。github

git clone https://github.com/tensorflow/models.git

完成以后就能看到一个model文件夹,固然,git命令使用的基础是你已经安装了git,怎么安装git本身百度吧。。api

下一步安装tensorflow,安装过的能够直接跳过。测试

# 若是你要用CPU,就用下面的代码
pip install tensorflow
#若是你用GPU,就用这里的代码
pip install tensorflow-gpu

固然,pip命令使用的基础是你已经安装了pip,若是你不会安装,请自行百度。ui

我默认你已经完成了上面的操做,下面就开始安装其余东西。google

sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
pip install --user Cython
pip install --user contextlib2
pip install --user jupyter
pip install --user matplotlib

命令行里输入以上的命令,完成Cython等库的安装。spa

下一步相当重要,你须要安装COCOAPI。命令行

在任何一个目录下将cocoapi 给git下来,进入python api目录,编译。

而后进入以前输入make以后的指令,清注意将<path_to_tensorflow>替换为models以前的绝对路径。

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tensorflow>/models/research/

这里你已经完成了不少工做,从models/research执行如下命令

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

#From tensorflow/models/research/
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

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

这段代码完成了对protobuf的编译工做,这只适用于linux。

接下来就是将pythonpath添加进path

# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

 

接下来就是测试是否安装成功了。

python object_detection/builders/model_builder_test.py

 

输入以上指令,若是出现

.....................
----------------------------------------------------------------------
Ran 21 tests in 0.074s

OK

代表你安装成功了。准备下一步吧。

相关文章
相关标签/搜索