1.环境配置

2.数据集获取

3.训练集获取

4.训练

5.调用测试训练结果

6.代码讲解

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

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

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

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

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

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

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

下一步安装tensorflow,安装过的可以直接跳过。

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

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

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

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等库的安装。

下一步至关重要,你需要安装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

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

 

相关文章:

  • 2021-12-29
  • 2021-08-22
  • 2021-05-09
  • 2021-08-14
  • 2021-12-04
  • 2022-01-01
  • 2021-10-17
  • 2021-06-22
猜你喜欢
  • 2021-11-10
  • 2021-11-02
  • 2021-08-09
  • 2021-11-09
  • 2021-12-18
  • 2021-09-25
  • 2021-09-24
相关资源
相似解决方案