Tensorflow Object Detection
前言
本文主要介绍如何利用官方库tensorflow/models/research/objection
并通过faster rcnn resnet 101(以及其他)深度学习框架
训练自己的数据集,并对训练结果进行检测和评估
准备工作
1. 准备自己的数据集
数据集文件目录如下
datas/
datas/
img/
xml/
disk_label_map.pbtxt
img/目录下为数据集图片
xml/目录下为图片对应的信息
15_11_09_53_513.xml
<?xml version="1.0" encoding="utf-8"?>
<annotation>
<folder>datas</folder>
<filename>jpg</filename>
<source>
<database>Unknown</database>
</source>
<size>
<width>564</width>
<height>430</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>rect</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>255</xmin>
<ymin>47</ymin>
<xmax>460</xmax>
<ymax>170</ymax>
</bndbox>
</object>
<object>
<name>rice</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>81</xmin>
<ymin>165</ymin>
<xmax>246</xmax>
<ymax>330</ymax>
</bndbox>
</object>
</annotation>
(其中object为检测到的物体,name代表物体类别与disk_label_map.pbtxt中指定的一致,bndbox检测到的区域)
disk_label_map.pbtxt
item {
id: 1
name: 'rice'
}
item {
id: 2
name: 'soup'
}
item {
id: 3
name: 'rect'
}
item {
id: 4
name: 'lcir'
}
item {
id: 5
name: 'ssquare'
}
item {
id: 6
name: 'msquare'
}
item {
id: 7
name: 'lsquare'
}
item {
id: 8
name: 'bsquare'
}
item {
id: 9
name: 'ellipse'
}
2.安装tensorflow-gpu
- 官网下载对应版本,安装nvidia-driver:https://www.nvidia.com/Download/index.aspx
- 安装cuda8.0,tensorflow只支持到cuda8.0: https://developer.nvidia.com/cuda-80-ga2-download-archive
- 安装cudnn6.0,更高的版本也不行:https://developer.nvidia.com/rdp/cudnn-download
- 安装virtualenv隔离的tensorflow-gpu(python)运行环境(virtualenv隔离不是必要)
$ sudo apt-get install python-virtualenv
$ virtualenv --system-site-packages tensorflow (在~目录下创建独立运行环境)