1© 2014 The MathWorks, Inc.
基于MATLAB的计算机视觉——插上人工智能的翅膀
MathWorks China
Application Engineer
Tom Shan
3
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
4
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
5
使用机器学习都能帮我们解决哪些问题?
Object Detection
Object Recognition or Classification
Clustering
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
7
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
8
使用图像进行机器学习的流程
Training Data Feature
Extraction
Learning or
Modelling
Training
Classifier / Model ‘hat’
Input Image Feature
ExtractionClassification
Classification
9
挑战:使用图像进行机器学习的流程
Training Data Feature
Extraction
Learning or
Modelling
Classifier / Model ‘hat’
Input Image Feature
ExtractionClassification
Challenge 1 Challenge 2
Challenge 2
Challenge 3
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
11
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
12
目标:对实时视频中的目标进行识别/分类
Known as object classification or recognition
vs vs
‘hat’ ‘mug’ ‘boat’
13Sparse Dense
SURF HOG Image
PixelsBag of Words
特征提取• 图像特征通常是对于缩放、旋转、亮度的改变,
具有一致性• 比直接存储像素数据,更加紧凑• 需根据实际问题,进行特征的选取
什么是特征提取?
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
15
Bag of “Visual Words” ( features)
‘mugs’Class / Label
Training Data
Vocabulary /
Bag of Words
16
使用Bag of Words进行图像识别/分类
Input Image
Classifier ‘hat’
Training DataBag = Visual
Vocabulary
Bag
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
20
挑战:使用图像进行机器学习的流程
Training Data Feature
Extraction
Learning or
Modelling
Classifier / Model ‘hat’
Input Image Feature
ExtractionClassification
Challenge 1 Challenge 2
Challenge 2
Challenge 3
21
Common Challenges for Machine Learning with Images
挑战1: 处理大量图像数据集
挑战2: 如何从图像中提取差别信息
挑战3: 如何使用机器学习技术对问题建模
方便操作的大量图像数据集– imageSet
将Bag of words 用于特征提取– 更多特征提取函数见Computer
Vision System Toolbox
Classification APP
22
Examples of Object Recognition/Classification
Automatic scene categorization
Biometrics
– Face recognition
– IRIS recognition
– Fingerprint recognition
Part recognition for factory automation
Autonomous robotics
26
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
27
基于MATLAB的目标检测
多种方法:
1. 特征检测、提取和匹配
2. 预先训练好的模型
3. Out-of-the box frameworks
– 从头开始设计分类器
– 两类分类器 ( classes are object and everything else )
28
Sliding
Window
Label,
Score
Extract
FeatureClassify
Patch
Object Detection is Classification
29
级联分类器 (Cascade classifier )
灵感 Boosting Cancer detection
CEA X AFP X CA153 XCA199 X CA125 =+99% accuracy
级联分类器的结构(Cascade classifier Structure)
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
31
总结: 创建目标检测器
使用MATLAB Apps 简化训练过程耗时
采用目标检测器架构快速搭建自定制目标检测器
大量预先训练的检测器可供使用
34
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
35
并行计算助理人工智能
Worker Worker
Worker
Worker
WorkerWorker
Worker
WorkerTOOLBOXES
BLOCKSETS
MATLAB并行计算实现:串行到并行
36
Worker Worker
Worker
Worker
WorkerWorker
Worker
WorkerTOOLBOXES
BLOCKSETS
MATLAB并行计算实现:串行到并行
37
MATLAB并行计算工具箱
使用并行计算工具箱
使本地计算加速
充分发挥CPU和GPU的各自计算能力
无需另外的计算资源
Desktop Computer
Parallel Computing Toolbox
38
易于扩展到集群,网格,和云
桌面计算
Parallel Computing Toolbox
计算集群
MATLAB Distributed Computing Server
Scheduler
39
工具箱内部函数支持
上层编程结构
parfor, batch, distributed
底层编程结构
createJob, labSend
易于
使用
便于
控制
CPU并行编程实现:少量代码修改
40
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
41
GPU加速卷积神经网络案例
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?
43
题纲
基于MATLAB的人工智能设计流程– 介绍
人工智能
流程和常见挑战
– 演示
针对实时视频进行目标检测
训练目标检测器
并行计算加速
– 集群
– GPU/多GPU加速
总结
45
Thank You!