From: TensorFlow Object Detection API

This chapter help you to train your own model to identify objects required.

1. Data

1.1 Get your own data

  • 标准的范例,从ImageNet上获取数据集

Get your own data from ImageNet

Download tiny-imagenet-200.zip, which is smaller than original monster. (150G)

  • 图片格式转化

We need .png but not .jpg here, so

cd ./images
ls -1 *.jpg | xargs -n 1 bash -c 'convert "$0" "${0%.jpg}.png"'

1.2 Create your Annotation.

  • 获取标记记录

Sol 01: 

# 找数据集上现成的对应的标记框记录

Find its xml version from: http://image-net.org/download-bboxes

Sol 02:

# 自己写标记记录

Write script to create your xml for Annotation from *_box.txt. This is not a complex structure as following.

<annotation>
<folder>n02119789</folder>
<filename>n02119789_122</filename>
<source>
<database>ImageNet database</database>
</source>
<size>
<width>200</width>
<height>191</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>n02119789</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>17</xmin>
<ymin>16</ymin>
<xmax>181</xmax>
<ymax>181</ymax>
</bndbox>
</object>
</annotation>

Sol 03: 

# 通过工具辅助生成标记框记录

Label them manually. This is a crazy way to create your train data (100-500 images) if you have enough time.

sudo apt-get install pyqt5-dev-tools
sudo pip3 install lxml
git clone https://github.com/tzutalin/labelImg
unsw@unsw-UX303UB$ make qt5py3
unsw@unsw-UX303UB$ python3 labelImg.py

  • 完整的数据集

Finally, this is what we need.

  • .csv 格式的数据集

Similarly, we need .csv but not .xml here, so

Download: https://raw.githubusercontent.com/datitran/raccoon_dataset/master/xml_to_csv.py

import os
import glob
import pandas as pd
import xml.etree.ElementTree as ET def xml_to_csv(path):
xml_list = []
for xml_file in glob.glob(path + '/*.xml'):
tree = ET.parse(xml_file)
root = tree.getroot()
for member in root.findall('object'):
value = (root.find('filename').text,
int(root.find('size')[0].text),
int(root.find('size')[1].text),
member[0].text,
int(member[4][0].text),
int(member[4][1].text),
int(member[4][2].text),
int(member[4][3].text)
)
xml_list.append(value)
column_name = ['filename', 'width', 'height', 'class', 'xmin', 'ymin', 'xmax', 'ymax']
xml_df = pd.DataFrame(xml_list, columns=column_name)
return xml_df def main():
image_path = os.path.join(os.getcwd(), 'annotations')
xml_df = xml_to_csv(image_path)
xml_df.to_csv('raccoon_labels.csv', index=None)
print('Successfully converted xml to csv.') main()

xml_to_csv.py

unsw@unsw-UX303UB$ python xml_to_csv.py
Successfully converted xml to csv.
unsw@unsw-UX303UB$ ls
annotations images Others raccoon_labels.csv xml_to_csv.py

This is final bounding box info.

2. Cascade Classifier Training


一、相关方案

Ref: https://docs.opencv.org/2.4/doc/user_guide/ug_traincascade.html

  • 接口

THE OPENCV TUTORIAL FOR TRAINING CASCADE CLASSIFIERS is a pretty good place to start. It explains the 2 binary utilities used in the process (opencv_createsamples and opencv_traincascade),

and all of their command line arguments and options, but it doesn’t really give an example of a flow to follow, nor does it explain all the possible uses for the opencv_createsamplesutility.

  • 方案一

On the other hand, NAOTOSHI SEO’S TUTORIAL is actually quite thorough and explains the 4 different uses for the opencv_createsamples utility.

THORSTEN BALL WROTE A TUTORIAL using Naotoshi Seo’s scripts to train a classifier to detect bananas, but it requires running some perl scripts and compiling some C++… too much work…

  • 方案二

Jeff also has some NICE NOTES about how he prepared his data, and a SCRIPT for automatically iterating over a couple of options for the 2 utilities.

The way we did it was inspired by all of these tutorials, with some minor modifications and optimizations.

二、Process

  • 是什么

Ref: https://processing.org/download/

一种语言,处理图像,提供了更为亲和的方式。

/* implement */

[Tensorflow] Object Detection API - prepare your training data的更多相关文章

  1. [Tensorflow] Object Detection API - build your training environment

    一.前期准备 Prepare protoc Download Protocol Buffers Create folder: protoc and unzip it. unsw@unsw-UX303U ...

  2. Tensorflow object detection API 搭建属于自己的物体识别模型

    一.下载Tensorflow object detection API工程源码 网址:https://github.com/tensorflow/models,可通过Git下载,打开Git Bash, ...

  3. [Tensorflow] Object Detection API - predict through your exclusive model

    开始预测 一.训练结果 From: Testing Custom Object Detector - TensorFlow Object Detection API Tutorial p.6 训练结果 ...

  4. TensorFlow object detection API应用

    前一篇讲述了TensorFlow object detection API的安装与配置,现在我们尝试用这个API搭建自己的目标检测模型. 一.准备数据集 本篇旨在人脸识别,在百度图片上下载了120张张 ...

  5. 使用TensorFlow Object Detection API+Google ML Engine训练自己的手掌识别器

    上次使用Google ML Engine跑了一下TensorFlow Object Detection API中的Quick Start(http://www.cnblogs.com/take-fet ...

  6. 基于TensorFlow Object Detection API进行迁移学习训练自己的人脸检测模型(二)

    前言 已完成数据预处理工作,具体参照: 基于TensorFlow Object Detection API进行迁移学习训练自己的人脸检测模型(一) 设置配置文件 新建目录face_faster_rcn ...

  7. Install Tensorflow object detection API in Anaconda (Windows)

    This blog is to explain how to install Tensorflow object detection API in Anaconda in Windows 10 as ...

  8. TensorFlow object detection API

    cloud执行:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pet ...

  9. Tensorflow object detection API 搭建物体识别模型(四)

    四.模型测试 1)下载文件 在已经阅读并且实践过前3篇文章的情况下,读者会有一些文件夹.因为每个读者的实际操作不同,则文件夹中的内容不同.为了保持本篇文章的独立性,制作了可以独立运行的文件夹目标检测. ...

随机推荐

  1. Java中使用Timer和TimerTask实现多线程

    转自:http://www.bdqn.cn/news/201305/9303.shtml 摘要:Timer是一种线程设施,用于安排以后在后台线程中执行的任务.可安排任务执行一次,或者定期重复执行,可以 ...

  2. Chromium OS 初体验

    Chromium OS可是早有耳闻,但是一直没有尝试,最近很多评论甚至认为会对Windows和Mac都能够造成压力,于是迫不及待的想尝试一下了,百度下了官网,官网很贴心,不光给了用于写入U盘的镜像文件 ...

  3. 9.5 dubbo事件通知机制

    dubbo事件通知机制:http://dubbo.io/books/dubbo-user-book/demos/events-notify.html 一.使用方式 两个服务: DemoService: ...

  4. 如何使用IconFont 图标

    第一步:使用font-face声明字体 @font-face {font-family: 'iconfont'; src: url('iconfont.eot'); /* IE9*/ src: url ...

  5. .NET 11 个 Visual Studio 代码性能分析工具

    原文地址 软件开发中的性能优化对程序员来说是一个非常重要的问题.一个小问题可能成为一个大的系统的瓶颈.但是对于程序员来说,通过自身去优化代码是十分困难的.幸运的是,有一些非常棒的工具可以帮助程序员进行 ...

  6. PL/SQL学习笔记之存储过程

    一:PL/SQL的两种子程序 子程序:子程序是执行一个特定功能.任务的程序模块.PL/SQL中有两种子程序:函数  和  过程. 函数:主要用于计算并返回一个值. 过程:没有直接返回值,主要用于执行操 ...

  7. Android中windowTranslucentStatus与windowTranslucentNavigation的一些设置(转)

    在iOS中,你可能发现页面会整体拉升到状态栏,整个页面效果就会显得更加的高端大气上档次,在Android4.4以后其实也有这种效果的实现,下面我就说一下在进行这种效果实现时碰到的一些坑,希望对大家有一 ...

  8. hdu2255 奔小康赚大钱,最大权匹配,KM算法

    点击打开链接 最大权匹配 KM算法 算法步骤: 设顶点Xi的顶标为a[i],顶点Yi的顶标为b[i] ⅰ.初始时.a[i]为与Xi相关联的边的最大权值.b[j]=0.保证a[i]+b[j]>=w ...

  9. 以太坊(Ethereum)智能合约NodeJS/Web3 使用

    一.概述 运行环境:Node.js.npm.Truffle.Solidity等 root@keke:~/go-ethereum# node -v v8.9.4 root@keke:~/go-ether ...

  10. 适合初学者的python实际例子

    最近在github上发现了一个有意思的项目,很适合初学者学习python代码. 学习一门语言刚开始的时候是很枯燥的,各种概念语法以及无聊的打印都会让人失去更进一步学习的动力. 很多同学在学习了一段时间 ...