machine learning for computer vision - mathworks · machine learning for computer vision author:...

36
1 © 2014 The MathWorks, Inc. 基于MATLAB的计算机视觉——插上人工智能的翅膀 MathWorks China Application Engineer Tom Shan

Upload: others

Post on 08-Jul-2020

37 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

1© 2014 The MathWorks, Inc.

基于MATLAB的计算机视觉——插上人工智能的翅膀

MathWorks China

Application Engineer

Tom Shan

Page 2: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

3

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 3: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

4

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 4: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

5

使用机器学习都能帮我们解决哪些问题?

Object Detection

Object Recognition or Classification

Clustering

Page 5: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

6

机器学习——Machine Learning

机器学习使用数据,并以此产生出一套用于特定任务的程序

Hand

Written

Program

If brightness > 0.5

then ‘hat’

If edge_density < 4 and

major_axis > 5

then “boat”

‘boats’

‘mugs’

‘hats’

Machine

Learning

𝑚𝑜𝑑𝑒𝑙 = <𝑴𝒂𝒄𝒉𝒊𝒏𝒆𝑳𝒆𝒂𝒓𝒏𝒊𝒏𝒈𝑨𝒍𝒈𝒐𝒓𝒊𝒕𝒉𝒎

>(data, label)

‘boats’

‘mugs’

‘hats’

Computer

Vision

任务: Image Category Recognition

Page 6: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

7

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 7: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

8

使用图像进行机器学习的流程

Training Data Feature

Extraction

Learning or

Modelling

Training

Classifier / Model ‘hat’

Input Image Feature

ExtractionClassification

Classification

Page 8: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

9

挑战:使用图像进行机器学习的流程

Training Data Feature

Extraction

Learning or

Modelling

Classifier / Model ‘hat’

Input Image Feature

ExtractionClassification

Challenge 1 Challenge 2

Challenge 2

Challenge 3

Page 9: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

10

基于图像机器学习的共同挑战

Challenge 1: Handling large sets of images

Challenge 2: How to extract discriminative information from images

Challenge 3: How to model tasks or data using machine learning

Page 10: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

11

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 11: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

12

目标:对实时视频中的目标进行识别/分类

Known as object classification or recognition

vs vs

‘hat’ ‘mug’ ‘boat’

Page 12: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

13Sparse Dense

SURF HOG Image

PixelsBag of Words

特征提取• 图像特征通常是对于缩放、旋转、亮度的改变,

具有一致性• 比直接存储像素数据,更加紧凑• 需根据实际问题,进行特征的选取

什么是特征提取?

Page 13: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

14

Perform image processing, analysis, and algorithm development

Image Processing Toolbox™ provides a comprehensive set of

reference-standard algorithms, functions, and apps for image

processing, analysis, visualization, and algorithm development.

You can perform image analysis, image segmentation, image

enhancement, noise reduction, geometric transformations, and

image registration. Many toolbox functions support multicore

processors, GPUs, and C-code generation.

Image Processing Toolbox supports a diverse set of imagetypes, including high dynamic range, gigapixel resolution, embedded

ICC profile, and tomographic. Visualization functions and apps let you

explore images and videos, examine a region of pixels, adjust color

and contrast, create contours or histograms, and manipulate regions

of interest (ROIs). The toolbox supports workflows for processing,

displaying, and navigating large images.

Image Processing Toolbox

Bag of Words

Class / Label

Training Data

Vocabulary /

Bag of Words

Page 14: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

15

Bag of “Visual Words” ( features)

‘mugs’Class / Label

Training Data

Vocabulary /

Bag of Words

Page 15: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

16

使用Bag of Words进行图像识别/分类

Input Image

Classifier ‘hat’

Training DataBag = Visual

Vocabulary

Bag

Page 16: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

19

Many Options for Features and Machine Learning

Feature Extraction

BRISK,FREAK, SURF

Histogram of Oriented Gradients

(HoG)

Using box filters(integral images )

Bag of visual words

Color-based features

Frequency-domain features

Machine Learning

SVM

Decision trees

AdaBoost

Bagged trees

k-NN

Discriminant analysis

Bayes classifiers

Bottom Line: Many permutations and combinations to fit the needs of your problem

Page 17: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

20

挑战:使用图像进行机器学习的流程

Training Data Feature

Extraction

Learning or

Modelling

Classifier / Model ‘hat’

Input Image Feature

ExtractionClassification

Challenge 1 Challenge 2

Challenge 2

Challenge 3

Page 18: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

21

Common Challenges for Machine Learning with Images

挑战1: 处理大量图像数据集

挑战2: 如何从图像中提取差别信息

挑战3: 如何使用机器学习技术对问题建模

方便操作的大量图像数据集– imageSet

将Bag of words 用于特征提取– 更多特征提取函数见Computer

Vision System Toolbox

Classification APP

Page 19: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

22

Examples of Object Recognition/Classification

Automatic scene categorization

Biometrics

– Face recognition

– IRIS recognition

– Fingerprint recognition

Part recognition for factory automation

Autonomous robotics

Page 20: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

26

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 21: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

27

基于MATLAB的目标检测

多种方法:

1. 特征检测、提取和匹配

2. 预先训练好的模型

3. Out-of-the box frameworks

– 从头开始设计分类器

– 两类分类器 ( classes are object and everything else )

Page 22: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

28

Sliding

Window

Label,

Score

Extract

FeatureClassify

Patch

Object Detection is Classification

Page 23: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

29

级联分类器 (Cascade classifier )

灵感 Boosting Cancer detection

CEA X AFP X CA153 XCA199 X CA125 =+99% accuracy

级联分类器的结构(Cascade classifier Structure)

Page 24: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

30

典型应用: Viola Jones Algorithm –Face detection

效率 : will quit at 1st stage for the majority of the area.

Features:

– HoG overall shape of the object people ,car detection

– LBP

– Haar

Tip : To save time, use small image set and use ‘HoG’ &‘LBP’ to decide

whether it is good with fine scale texture or overall shape.

Fine scale texture face ,nose,eye etc

Page 25: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

31

总结: 创建目标检测器

使用MATLAB Apps 简化训练过程耗时

采用目标检测器架构快速搭建自定制目标检测器

大量预先训练的检测器可供使用

Page 26: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

34

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 27: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

35

并行计算助理人工智能

Worker Worker

Worker

Worker

WorkerWorker

Worker

WorkerTOOLBOXES

BLOCKSETS

MATLAB并行计算实现:串行到并行

Page 28: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

36

Worker Worker

Worker

Worker

WorkerWorker

Worker

WorkerTOOLBOXES

BLOCKSETS

MATLAB并行计算实现:串行到并行

Page 29: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

37

MATLAB并行计算工具箱

使用并行计算工具箱

使本地计算加速

充分发挥CPU和GPU的各自计算能力

无需另外的计算资源

Desktop Computer

Parallel Computing Toolbox

Page 30: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

38

易于扩展到集群,网格,和云

桌面计算

Parallel Computing Toolbox

计算集群

MATLAB Distributed Computing Server

Scheduler

Page 31: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

39

工具箱内部函数支持

上层编程结构

parfor, batch, distributed

底层编程结构

createJob, labSend

易于

使用

便于

控制

CPU并行编程实现:少量代码修改

Page 32: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

40

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 33: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

41

GPU加速卷积神经网络案例

Page 34: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

42

多GPU加速

‘useParallel’ ‘yes’’no’

'useGPU‘ ‘yes’ ‘no’ ‘only’

自动在大型神经网络训练时保留Checkpoints

By default, checkpoint saves occur at most once every 60 seconds.

Save to .mat file, and load easily

What if GPU + CPU?

Page 35: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

43

题纲

基于MATLAB的人工智能设计流程– 介绍

人工智能

流程和常见挑战

– 演示

针对实时视频进行目标检测

训练目标检测器

并行计算加速

– 集群

– GPU/多GPU加速

总结

Page 36: Machine Learning for Computer Vision - MathWorks · Machine Learning for Computer Vision Author: Avi Nehemiah Keywords: Version 14.0 Created Date: 6/15/2016 3:14:44 PM

45

Thank You!