176
1 Random Forestsとその応用 http://mprg.jp/tutorials 機械知覚&ロボティクス研究グループ(中部大学)

Random Forestsとその応用

Embed Size (px)

Citation preview

Page 1: Random Forestsとその応用

1

Random Forestsとその応用

http://mprg.jp/tutorials

機械知覚&ロボティクス研究グループ(中部大学)

中部大学工学部 ロボット理工学科

宮腰 あゆみ機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of Engineering

Ayumi Miyakoshi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 ロボット理工学科助手

山内 悠嗣機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-8249Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of EngineeringResearch Assistant

Dr.Eng.Yuji Yamauchi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-8249Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 情報工学科講師

山下 隆義機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9670Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Computer ScienceCollege of EngineeringLecturer

Dr.Eng.Takayoshi Yamashita

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9670Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 ロボット理工学科教授

藤吉 弘亘機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of EngineeringProfessor

Dr.Eng.Hironobu Fujiyoshi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 ロボット理工学科

宮腰 あゆみ機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of Engineering

Ayumi Miyakoshi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 ロボット理工学科助手

山内 悠嗣機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-8249Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of EngineeringResearch Assistant

Dr.Eng.Yuji Yamauchi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-8249Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 情報工学科講師

山下 隆義機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9670Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Computer ScienceCollege of EngineeringLecturer

Dr.Eng.Takayoshi Yamashita

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9670Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

中部大学工学部 ロボット理工学科教授

藤吉 弘亘機械知覚&ロボティクスグループ487-8501愛知県春日井市松本町1200Tel 0568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

博士(工学)

MACHINE PERCEPTION AND ROBOTICS GROUP

Chubu UniversityDepartment of Robotics Science and TechnologyCollege of EngineeringProfessor

Dr.Eng.Hironobu Fujiyoshi

Machine Perception and Robotics Group1200 Matsumoto-cho, Kasugai, Aichi487-8501 JapanTel +81-568-51-9096Fax [email protected]://vision.cs.chubu.ac.jp

MACHINE PERCEPTION AND ROBOTICS GROUP

Page 2: Random Forestsとその応用

はじめに

1. Random Forests - 学習アルゴリズム

2. 学習を用いたキーポイントマッチングの高速化 - Random Forestsを用いたキーポイントマッチング - 2段階Random Forestsによる高精度化

3. Random Forestsを用いた物体検出 4. Random Forestsを用いた人体姿勢推定 5. Regression Forests 6. その他の問題設定への応用 - Density Forests - Semi-Supervised Forests

2

Page 3: Random Forestsとその応用

Random Forests [Breiman, 2001]

• アイデア ‒ 決定木学習 + アンサンブル学習 + ランダム学習 • 別名

‒ Randomized Trees ‒ Randomized Forests ‒ Randomized Decision Forests ‒ (Random) Ferns

• できること ‒ マルチクラス識別 ‒ クラスタリング

• 特徴 ‒ シンプルかつ高速な学習と識別

3

Page 4: Random Forestsとその応用

CVへの応用:キーポイントマッチング

[Lepetit et al., 2006]4

Page 5: Random Forestsとその応用

CVへの応用:物体認識&セグメンテーション

[Shotton et al., 2008]

5

Page 6: Random Forestsとその応用

CVへの応用:その他

• 文字認識 [Amit & Geman, 1997] • visual word クラスタリング[Moosmann et al., 2006] • 行動認識&姿勢推定[山下 et al., 2010]

6図 13 各ノードにおける事前選択特徴とクラス分割結果例

うに,下位ノードでは各行動クラスを認識するための特徴が多く選択されている.提案手法で導入した事前特徴選択により,上位ノード

は多数のクラスに共通する特徴,下位ノードは特定のクラスに対応する特徴を階層的に選択することができている.これにより,1つのフレームワークで階層的に人体検出から姿勢推定,行動認識を実現している.

6. ま と め我々は,人の行動を理解するために,人体検出から行

動認識までを 1つのフレームワークで実現する BoostedRandomized Treesを提案した.提案手法は,決定木のノード生成時に各クラスの尤度をもとに認識対象となるクラスを定義し,Joint Boostingにより効率的に特徴を選択することで,上位ノードは多数のクラスに対応した特徴,下位ノードは特定のクラスに対応した特徴を階層的に選択することが可能である.今後は,姿勢のバリエーションを増加させていくとともに,一般物体認識などに応用していく.

文 献[1] L. Breiman, “Random forests”, Machine Learning,

No.45(1), pp. 5-32, 2001.[2] P. Geurts, D. Ernst, and L. Wehenkel, “Extremely

randomized trees”,Machine Learning,No.36,Vol.1,pp. 3-42,2006.

[3] V. Lepetit, P. Lagger, and P. Fua,“Randomized treesfor real-time keypoint recognition”,IEEE Conf. onComputer Vision and Pattern Recognition,pp. 775-781,2005.

[4] J. Shotton, M. Johnson, R. Cipolla, “Semantic Tex-ton Forests for Image Categorization and Segmenta-tion”, IEEE Conf. on Computer Vision and PatternRecognition, 2008.

[5] N. Dalal and B. Triggs,“Histograms of oriented gra-dients for human detection”,IEEE Conf. on Com-puter Vision and Pattern Recognition, 2005.

[6] Q. Zhu, S. Avidan, M. C. Yeh, and K. T. Cheng,“Fast human detection using a cascade of histogramsof oriented gradients,IEEE Conf. on Computer Vi-sion and Pattern Recognition, Vol. 2, pp. 1491-1498,2006.

[7] C. Hou, H. Ai and S. Lao,“Multiview PedestrianDetection Based on Vector Boosting”,Asian Conf.

of Computer Vision, pp. 210-219,2007.[8] M. Blank, L. Gorelick, E. Shechtman, M. Irani,and

R.Basri. “Actions as space-time shapes”, IEEE Intl.Conf. of Computer Vision, 2005.

[9] J. C. Niebles and L. Fei-Fei. “A hierarchical modelof shape and appearance for human action classifica-tion”, IEEE Conf. on Computer Vision and PatternRecognition, 2007.

[10] K. Schindler and L. Van Gool,“Action snippets:How many frames does human action recognition re-quire?”,IEEE Conf. on Computer Vision and PatternRecognition, 2008.

[11] A. Fathi and G. Mori,“Human pose estimation us-ing motion exemplars”, IEEE Intl. Conf. of ComputerVision, 2007.

[12] G. Shakhnarovich, P. Viola, D. Trevor, “Fast poseestimation with parameter-sensitive hashing”, IEEEIntl. Conf. of Computer Vision, 2003.

[13] A. Bissacco, M.-H. Yang and S. Soatto, “Fast hu-man pose estimation using appearance and motion viamulti-dimensional boosting regression”, IEEE Conf.on Computer Vision and Pattern Recognition, 2007.

[14] G. Rogez, J. Rihan, S. Ramalingam, C. Orrite and P.H.S. Torr, “Randomized Trees for Human Pose Detec-tion”, IEEE Conf. on Computer Vision and PatternRecognition, 2008.

[15] A. Bissacco, M.-H.Yang and S. Soatto, “Detecting hu-mans via their pose”, In NIPS, pp. 169-176, 2006.

[16] A. Torralba, K. P. Murphy and W. T. Free-man,”Sharing features: efficient boosting proceduresfor multiclass object detection”,IEEE Conf. on Com-puter Vision and Pattern Recognition, 2004.

[17] Z. Tu,”Probabilistic boosting-tree: learning discrim-inative models for classification, recognition and clus-tering”,IEEE Intl. Conf. of Computer Vision, 2005.

[18] J. Gall and V.Lempitsky, ”Class-specific hough forestsfor object detection”,IEEE Conf. on Computer Vi-sion and Pattern Recognition, 2009.

[19] R. Okada,”Discriminative and Generalized HoughTransform for Object Detection”,IEEE Intl. Conf.of Computer Vision, 2009.

Page 7: Random Forestsとその応用

CVへの応用4:人検出

• パーツベースの人検出 [三井 et al., 2011]

‒ 人の領域をパーツに分割し、RFsによるマルチクラス識別器を構築

7

提案手法

従来法

C0 C1 C2 C3 C4 C5

+ + + … = ) ( Ave

Tree0 Tree1 TreeT-1

… … …

Randomized Trees マルチクラス識別器

0.61 0.29 = 0.32 h0 =

Page 8: Random Forestsとその応用

Random Forestsの特徴

• メリット ‒ 高速な学習・識別 • ランダム学習により高次元特徴(数万~)でも効率的な学習が可能 • 選択された特徴量のみで識別

‒ 教師信号のノイズに強い • 学習データのランダム選択によりノイズの影響を抑制

• デメリット ‒ オーバーフィッティングになりやすい • パラメータが多い(木の数,木の深さ,サブセット) • 学習データ数が少ないとうまく学習できない→ 大量の学習データを取得 or 生成する工夫が必要

8

Page 9: Random Forestsとその応用

マルチクラス識別器の比較(思いっきり主観です!)

SVM (one-vs-rest)

Boosting (Joint Boosting)

Random Forests

学習データの数 少 中 多

ノイズの影響 少 大 少

学習時間 中 遅い 速い

識別時間 遅い 中 速い

9

Page 10: Random Forestsとその応用

1. Random Forests の学習アルゴリズム

10

Page 11: Random Forestsとその応用

木構造を利用した識別器

決定木の数

深さ

D

1. 0.8 1.2 3.4 ... 3.2 2. 0.2 2.3 4.2 ... 4.2 3. 1.1 4.1 2.6 ... 6.7 4. 4.2 1.3 2.1 ... 2.4

1. 2.3 5.2 1.2 ... 6.2 2. 0.2 5.2 3.4 ... 7.2 3. 1.1 2.5 5.2 ... 3.2 4. 1.2 3.6 6.2 ... 6.3

学習サンプル

tree1 treeT

末端ノード

分岐ノード

カテゴリ1 カテゴリ2

1. 2.1 1.2 2.5 ... 2.6 2. 1.2 2.7 7.4 ... 3.2 3. 2.1 3.1 3.3 ... 8.5 4. 1.7 4.2 8.2 ... 2.1

カテゴリC

0

1

2

3

11

Page 12: Random Forestsとその応用

・前処理 − データ集合 S から T 個のサブセット作成

・For t = 1, 2, …, T  サブセットの数だけ木を作成 - IF エントロピー H(S)=0 or 指定した深さDに達した

・末端ノード作成 - ELSE ・分岐関数候補をランダムに K 個選択 ・ For k = 1, 2, …, K

- 候補 k を用いてサンプルの分割 - 候補 k の情報利得算出

・最も情報利得Iが高い候補を選択 ・単純ベイズ識別器作成

学習アルゴリズム

Random Forestsの学習アルゴリズム

12

Page 13: Random Forestsとその応用

サブセットの作成

• サンプル集合 S を用意 ‒ サンプルi ∈ S には特徴ベクトル vi, 教師信号 ci が付与

• サブセットの作成 ‒ T 個のサブセットをランダムに作成

13

サブセット S1 サブセット S2 サブセット ST

サンプル集合 S

Page 14: Random Forestsとその応用

サブセット作成のポイント

• サブセット間のサンプルの数は統一 ‒ 木の数と密接な関係

• 完全なランダム選択 ‒ サブセット間でのサンプルの重複を許容 ‒ 学習に利用されないサンプルも許容

14

サンプル集合 S

サブセット S1 サブセット S2 サブセット ST

Page 15: Random Forestsとその応用

学習アルゴリズム

15

・前処理 − データ集合 S から T 個のサブセット作成

・For t = 1, 2, …, T  サブセットの数だけ木を作成 - IF エントロピー H(S)=0 or 指定した深さDに達した

・末端ノード作成 - ELSE ・分岐関数候補をランダムに K 個選択 ・ For k = 1, 2, …, K

- 候補 k を用いてサンプルの分割 - 候補 k の情報利得算出

・最も情報利得Iが高い候補を選択 ・単純ベイズ識別器作成

Random Forestsの学習アルゴリズム

Page 16: Random Forestsとその応用

• 一般的には2つの方法が取られる ‒ 情報量を基準として複数の候補から良いものを選択 ( K>1 ) • Random Forests[ L. Breiman 01 ] • Semantic Texton Forests[ J. Shotton 08 ]

‒ 単純にランダム選択 ( K=1 ) • Extremely Randomized Trees[ P. Geurts 06 ] • Keypoint Matching [ V.Lepetit ’08 ]

分岐関数の決定方法

16

Page 17: Random Forestsとその応用

分岐関数の設計

• 基本的に設計は自由 ‒ しきい値,特徴量の大小関係

• Semantic Texton Forestsではしきい値を利用

17

f(p) = Px1,y1,c1

f(p) = Px1,y1,c1 + Px2,y2,c2

f(p) = Px1,y1,c1 � Px2,y2,c2

f(p) = |Px1,y1,c1 � Px2,y2,c2 |

i

p

Pixel&i&gives&patch&p (21x21 pixels'in'experiments)'

:左に分岐 :右に分岐

�f(v) < totherwise分岐ルール:

Page 18: Random Forestsとその応用

分岐関数候補の選択

• 学習サンプルの特徴ベクトルから候補を選出 ‒ 分岐関数 f と しきい値 t の組み合わせをK個ランダムに選択

• 例:1000次元の特徴ベクトル

18

特徴次元

Freq

.

1 2 3 4 5 6 7 8 1000999998997996995994993

1.0

候補数 K = √(特徴次元数1000) ≒ 32 が推奨されている[Breiman ’01]

(2, 0.1)1, ( 993, 0.3 )2, ( 6, 0.2 )3, ( 999, 0.2 )4, ... , ( 4, 0.3 )K{ }

Page 19: Random Forestsとその応用

分岐関数候補数とランダム性

• 分岐関数候補数を多く設定 ‒ ランダム性の低い決定木 ‒ 学習時間が増加 ‒ 識別性能の向上

• 分岐関数候補数を少なく設定 ‒ ランダム性の高い決定木 ‒ 学習時間の削減 ‒ 識別性能の低下

19

Page 20: Random Forestsとその応用

学習アルゴリズム

20

・前処理 − データ集合 S から T 個のサブセット作成

・For t = 1, 2, …, T  サブセットの数だけ木を作成 - IF エントロピー H(S)=0 or 指定した深さDに達した

・末端ノード作成 - ELSE ・分岐関数候補をランダムに K 個選択 ・ For k = 1, 2, …, K

- 候補 k を用いてサンプルの分割 - 候補 k の情報利得算出

・最も情報利得Iが高い候補を選択 ・単純ベイズ識別器作成

Random Forestsの学習アルゴリズム

Page 21: Random Forestsとその応用

サンプルの分割と情報利得の算出

• 分岐関数候補を用いてサンプルを分割

• 情報利得 I により候補を評価

21

Sl : 左に分岐するサンプル集合 Sr : 右に分岐するサンプル集合

H : 情報エントロピー Sj : 親ノードのサンプル集合

Ij = H(Sj)��

i=L,R

|Sij |

|Sj |H(Sij)

Sl = {i � Sj |fk(vi) < tk}Sr = Sj \ Sl

= H(Sj)�|Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

Page 22: Random Forestsとその応用

情報エントロピー

• カテゴリの出現確率の偏りを表す ‒ クラスの出現確率に偏りが少ない場合エントロピーは大

22

エントロピー

0.00

0.25

0.50

0.75

1.00

カテゴリ1の出現確率0.0 0.2 0.4 0.6 0.8 1.0

2カテゴリの出現確率とエントロピー

エントロピー :

H(S) = �C�

c=1

Pc log2 Pc

Page 23: Random Forestsとその応用

情報利得

• ノードを分割後に減少したエントロピーの量

23

候補1 候補2

親ノードSj

情報利得: Ij = H(Sj)�|Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

H(SL1 ) = �2

4log2

24� 2

4log2

24

= 0.5 + 0.5 = 1.0

H(SR2 ) = �4

4log2

44� 0

4log2

04

= 0.0 + 0.0 = 0.0

H(Sj) = �58

log258� 3

8log2

38

= 0.425 + 0.529 = 0.954

H(SR1 ) = �3

4log2

34� 1

4log2

14

= 0.311 + 0.5 = 0.811

H(SL2 ) = �3

4log2

34� 1

4log2

14

= 0.311 + 0.5 = 0.811

0.5490.0485

I2 = 0.954� 48� 0.811� 4

8� 0.0I1 = 0.954� 4

8� 1.0� 4

8� 0.811

親ノードのエントロピー

候補1のエントロピー

候補2のエントロピー

Page 24: Random Forestsとその応用

実装上の情報利得

• 親ノードの情報エントロピーは変化しない

→子ノードのエントロピーが最大となる候補を選択 →計算コストの削減

24

I1 = 0.954� 48� 1.0� 4

8� 0.811

= 0.0485

I2 = 0.954� 48� 0.811� 4

8� 0.0

= 0.549

Ij = H(Sj)�|Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

Ij = � |Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

実装上の情報利得

Page 25: Random Forestsとその応用

分岐ノード決定過程

• 分岐ノード決定シミュレーション ‒ 分岐関数:2次元空間を分割する一次関数 ‒ 3つの分岐関数から最適なものを見つける

25x

y

12

3カテゴリ数 : 4 サンプル数 : 4 × 33

Page 26: Random Forestsとその応用

分岐ノード決定過程1

• 分岐関数候補1

26

x

12

3

情報利得 :

Pl (c)

0.01

0.500.490

Pr (c)

0.49

0 0.010.50

エントロピー :

x

y1

Sl Sr

H(S) = �C�

c=1

Pc log2 Pc

H(Sl) = 1.10

H(Sr) = 1.10

I = � |Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

I1 = �1.10

y

Page 27: Random Forestsとその応用

分岐ノード決定過程2

• 分岐関数候補2

27

x

12

3

Pl (c)

0

0.500.50

0

Pr (c)

0.50

0 0

0.50

x

y 2

Sl Sr

I2 = �1.0

H(Sr) = 1.0

H(Sl) = 1.0

情報利得 :

エントロピー : H(S) = �C�

c=1

Pc log2 Pc

I = � |Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

y

Page 28: Random Forestsとその応用

分岐ノード決定過程3

• 分岐関数候補3

28

y1

2

3

Pl (c)

0

0.460.51

0.03

Pr (c)

0.490.040

0.46

x

y

3

Sl

SrH(Sl) = 1.16

H(Sr) = 1.21

情報利得 :

エントロピー : H(S) = �C�

c=1

Pc log2 Pc

I = � |Sl||Sj |H(Sl)�

|Sr||Sj |H(Sr)

I3 = �1.185

x

Page 29: Random Forestsとその応用

分岐ノード決定過程4

• 分岐ノード決定シミュレーション ‒ 分岐関数:2次元空間を分割する一次関数 ‒ 3つの分岐関数から最適なものを見つける

29

x

y

12

3

カテゴリ数 : 4 サンプル数 : 4 × 33

→分岐関数候補 2 を選択

max

I1 = �1.10

I2 = �1.0

I3 = �1.185

Page 30: Random Forestsとその応用

学習アルゴリズム

30

・前処理 − データ集合 S から T 個のサブセット作成

・For t = 1, 2, …, T  サブセットの数だけ木を作成 - IF エントロピー H(S)=0 or 指定した深さDに達した

・末端ノード作成 - ELSE ・分岐関数候補をランダムに K 個選択 ・ For k = 1, 2, …, K

- 候補 k を用いてサンプルの分割 - 候補 k の情報利得算出

・最も情報利得Iが高い候補を選択 ・単純ベイズ識別器作成

Random Forestsの学習アルゴリズム

Page 31: Random Forestsとその応用

末端ノードの作成条件

• エントロピー H(S) が0になった時 ‒ これ以上分岐が出来ないのため終了

• 指定した深さD まで学習が進んだ時 ‒ 過学習を防ぐため

31

Page 32: Random Forestsとその応用

エントロピー H(S) が0になる場合

• Sr と Sl に単一カテゴリのサンプルが属する状態になる → 分岐ができない

32

x

y

P (c)

1.0

エントロピー :

32

H(S) = �C�

c=1

Pc log2 Pc

H(Sj) = 0.0

Page 33: Random Forestsとその応用

指定した深さに達する場合

• 木が深くなるほど過学習になる

33

x

y

例:最大の深さ3で学習

1

2

3

0

→ 指定した深さに成長したため 末端ノード

→木の深さを制限して対応

Page 34: Random Forestsとその応用

末端ノード作成

• カテゴリの出現確率Pn (c) ‒ サンプル集合Sに付与された教師信号を投票

34

サブセット St

確率

カテゴリ C

Page 35: Random Forestsとその応用

・前処理 − データ集合 S から T 個のサブセット作成

・For t = 1, 2, …, T  サブセットの数だけ木を作成 - IF エントロピー H(S)=0 or 指定した深さDに達した

・末端ノード作成 - ELSE ・分岐関数候補をランダムに K 個選択 ・ For k = 1, 2, …, K

- 候補 k を用いてサンプルの分割 - 候補 k の情報利得算出

・最も情報利得Iが高い候補を選択 ・単純ベイズ識別器作成

学習アルゴリズム

35

Random Forestsの学習アルゴリズム

Page 36: Random Forestsとその応用

単純ベイズ識別器の作成

• T 個の決定木をトラバーサル

36

……tree t1 tree tT

v v

P1(c|v) Pt(c|v)

P (c|v) =1T

T�

t=1

Pt(c|v)識別結果の統合:

単純ベイズ識別器: C�i = arg max

ci

P (ci|v)

+ …… +

Average

=T 87 654 32

1

Page 37: Random Forestsとその応用

実装上の注意点

• 学習サンプルの各クラスのサンプル数が不均等の場合 → Inverse Label Frequencyが必要

• 学習サンプル I すべてを用いてクラスの頻度分布を作成 ‒ あるサンプル i ∈ I に付けられているラベルを ciを利用

• カテゴリの頻度分布作成時に重み付け

37

�c =

��

i�I

[c = ci]

��1

カテゴリ C

頻度

Page 38: Random Forestsとその応用

Random Forestsによる学習過程

• トイプロブレムを利用して学習過程を観察

38

・分類問題:3クラス ・特徴次元:2次元

・学習パラメータ 木の数 1 分岐候補 25 深さ 4

480

6400

トイプロブレム

Page 39: Random Forestsとその応用

学習過程1

• 深さ1

39

I :−0.68 特徴量  :x しきい値 :393

0 393

ノード

480

640

Page 40: Random Forestsとその応用

学習過程2

• 深さ2

40

640

480

0 233

I :−0.04 特徴量  :x しきい値 :233

ノード

Page 41: Random Forestsとその応用

学習過程3

• 深さ3

41

480

6400

212

I :−0.23 特徴量  :y しきい値 :227

ノード

Page 42: Random Forestsとその応用

学習過程4 (終了)

• 深さ4

42

480

6400 256 I :0.0 特徴量  :x しきい値 :256

ノード

Page 43: Random Forestsとその応用

パラメータ調整のコツ

• 過学習を回避するためには ‒ 深さを浅く設定する

• 表現能力をあげるためには ‒ 木の数を増やす

• 分岐ノード候補数 ‒ √特徴次元数 が推奨

• サブセットに分けるデータの数 ‒ サブセット間で若干重複がある程度の数

43

Page 44: Random Forestsとその応用

木の数による識別境界の変化

44

Page 45: Random Forestsとその応用

木の数による識別境界の変化

• 分岐関数の候補数:15

45

木の数:5 木の数:300

→マージン最大化

Page 46: Random Forestsとその応用

Random Forestsのソースコード

• Random Forestsの学習,識別 ‒ URL : http://www.vision.cs.chubu.ac.jp/CVTutorial/ ‒ Dataset : 人工生成サンプル ‒ 作成環境 : Visual Studio Ver. 2008, C++ ‒ 学習プログラム:main_training.cpp ‒ 学習パラメータの設定 • Learn関数の引数に設定(numTrees, maxDepth, featureTrials, thresholdTrials, dataPerTree)

‒ 識別プログラム:main_evaluate.cpp

46

Page 47: Random Forestsとその応用

2. 学習を用いたキーポイントマッチングの高速化 - Random Forestsを用いたキーポイントマッチング - 2段階Random Forestsによる高精度化 - Ferns

47

Page 48: Random Forestsとその応用

Boosted Random Forest[MIRU2013]

• RandomForestにBoostingアルゴリズムを導入

48

認識性能を維持しながら平均47%のメモリ削減を実現

Page 49: Random Forestsとその応用

まとめ:Random Forests

• Random Forests ‒ 決定木を用いたマルチクラス識別器 ‒ 高速な学習・識別

• Boosted Random Forest

49

Page 50: Random Forestsとその応用

SIFTアプローチの変遷

50

Lowe:SIFT

Ke, Sukthankar:PCA-SIFT

頑健性の向上

Mikolajczyk, Schmid:GLOH

頑健性の向上Bay et al.:

SURF

手法の高速化

Sinha, Sudipta:SIFT-GPU

GPU を用いた高速化

高精度

高速

学習なし

1999

2004

2006

2006

2005

Lepetit, Fua:RTs

学習あり

2006

高速・高精度化

Page 51: Random Forestsとその応用

Random Forestsによるキーポイントマッチング [Lepetit’06]

• 決定木を用いたキーポイントの分類 ‒ 学習 • テンプレートをアフィン変換して学習画像を作成 • 学習画像すべてからキーポイントを検出 • キーポイントを中心とした32×32のパッチを作成 • 決定木の構築

‒ 分類によるマッチング • 入力画像からキーポイント検出 • キーポイントを中心とした32×32のパッチを作成 • 決定木によりキーポイントをマッチング

51

Page 52: Random Forestsとその応用

学習画像の生成

• 見えの変化に対応するためテンプレートをアフィン変換 ‒ ランダムなパラメータでアフィン変換行列を作成 • 回転,スキュー,平行移動,スケール

52

( x , y ):テンプレート上の座標 ( x’ , y’ ):アフィン変換後の座標

Page 53: Random Forestsとその応用

アフィン変換に頑健なキーポイント選択

• 学習画像すべてからキーポイントを抽出 ‒ 逆行列によりテンプレート上の対応するキーポイント算出 ‒ 同一位置のキーポイント数をカウント ‒ 多くの画像から検出されたキーポイントを検出(例:200)→ノイズおよびひずみに安定したキーポイントを選択

53

Page 54: Random Forestsとその応用

Random Forestsの構築

・・・学習画像

キーポイント

キーポイント

キーポイント ・・・

・・・

・・・

・・・

サブセット1 サブセット2 サブセットN

≦ >

≦ >

ピクセルの位置はランダムに選択

54

Page 55: Random Forestsとその応用

キーポイントの分類

テンプレート 入力画像

32×32

+ +( + )  Average =・・・

・・・

Tree1 Tree2 TreeN

≦ > ≦ > ≦ >

c55

Page 56: Random Forestsとその応用

ノードに利用する特徴量

• 2ピクセルを用いた手法 • 4ピクセルを用いた手法 • SIFT特徴量を用いた手法

56

≦ >

2ピクセル間の輝度

−− ≦ > −−

2ピクセル対(4ピクセル)の輝度差

≦ >

SIFTヒストグラム間の差

Page 57: Random Forestsとその応用

ノードにおける特徴(2ピクセルを用いた手法)

• 2ピクセル間の輝度差

57

m:ピクセル

P:パッチ

Iσ:平滑化後の画像

≦ >

2ピクセル間の輝度差

Page 58: Random Forestsとその応用

ノードにおける特徴(4ピクセルを用いた手法)

• 2つのピクセル対の関係性

58

−− ≦ > −−

2ピクセル対(4ピクセル)の輝度差

m:ピクセル

P:パッチ

Iσ:平滑化後の画像

Page 59: Random Forestsとその応用

ノードにおける特徴(SIFT特徴量を用いた手法)

• パッチから得られるSIFT特徴量を使用

59

u

v o

Bin(u, v, o)

≦ >

SIFTヒストグラム間の差

Page 60: Random Forestsとその応用

特徴量の評価実験

• 実験データ ‒ Title:タイトル領域のキーポイント100個 ‒ Eyes:画像(目)良識のキーポイント100個

• 比較手法 ‒ C2:2ピクセルを用いた手法 ‒ C4:4ピクセルを用いた手法 ‒ Ch:SIFT特徴量を用いた手法

60Advice on writing a book by Prof. Hartley (ICCV2011)

Page 61: Random Forestsとその応用

特徴量の評価結果

• 実験結果 ‒ 木の数が増えるほど精度が高い ‒ C4はC2より精度が低い ‒ ChはC2より精度が高いが、計算コストが高い

61

C2 C4 Ch

Title set

depth10

depth12

depth15

60.7%

69.2%

77.0%

57.7%

65.1%

73.7%

66.6%

75.0%

82.4%

Eyes set

depth10

depth12

depth15

72.7%

78.6%

84.7%

70.0%

76.1%

81.4%

74.5%

84.2%

84.2%

マッチング精度

Page 62: Random Forestsとその応用

SIFTによるマッチング結果

対応点数:18 正解点数: 562

Page 63: Random Forestsとその応用

SURFによるマッチング結果

対応点数:25 正解点数:1363

Page 64: Random Forestsとその応用

Random Forestsによるマッチング結果

対応点数:38 正解点数:3864

Page 65: Random Forestsとその応用

2. 学習を用いたキーポイントマッチングの高速化 - Random Forestsを用いたキーポイントマッチング - 2段階Random Forestsによる高精度化 - Ferns

65

Page 66: Random Forestsとその応用

Random Forestsによるマッチング精度

検出例(70度):1/4 (25%)

検出例(40度):217/217 (100%)

射影変化が大きいと精度が低下66

Page 67: Random Forestsとその応用

2段階のRandom Forestsによる高精度化 [西村 et al., 2010]

• 学習画像の生成 ‒ 3次元上の回転を表現

• 決定木の構築 ‒ 視点変化とキーポイント多様性を同じRandom Forestsで表現

67

2段階にRandom Forestsを構築

→ 視点の変化とキーポイントの多様性を個々のRandom Forestsで表現

Page 68: Random Forestsとその応用

前処理:学習画像の生成

• オイラー角を用いて3次元上の回転を表現 ‒ Viewpointをψθφ回転角で定義

68

Viewpoint

z

Page 69: Random Forestsとその応用

学習画像の生成例

0 36 72 108 144 180 216 251 288 324

45

60

70

φ

ψ=90

θ

69

Page 70: Random Forestsとその応用

提案手法:2段階のRandom Forests

Keypoint分類結果

学習画像

Viewpointクラス3に分類Tree 1 Tree 2 Tree N1

・・・

Viewpoint分類のためのRandom Forests

入力画像

Viewpointクラス3

Viewpointクラス2

Viewpointクラス1

Tree 1 Tree 2 Tree N2

・・・

Keypoint分類のためのRandom Forests

70

Page 71: Random Forestsとその応用

提案手法:2段階のRandom Forests

Keypoint分類結果

学習画像

Viewpointクラス1に分類Tree 1 Tree 2 Tree N1

・・・

Viewpoint分類のためのRandom Forests

入力画像

Viewpointクラス3

Viewpointクラス2

Viewpointクラス1

Tree 1 Tree 2 Tree N2

・・・

Keypoint分類のためのRandom Forests

71

Page 72: Random Forestsとその応用

1段階目:Viewpointの分類

入力画像

セントロイド画像

Viewpointクラス1 3010 20

クラス1に分類

72

Page 73: Random Forestsとその応用

1段階目:Viewpointの分類

セントロイド画像

クラス12に分類

1 3010 20入力画像Viewpointクラス

73

Page 74: Random Forestsとその応用

2段階目:キーポイント分類のRandom Forestsの構築

・・・

サブセットTサブセット2

サブセット1:1:1:1

:1

:1:1

Viewpointクラス1

サブセットT2サブセット2

サブセット1:2:2:2

:2:2:2

Viewpointクラス2

サブセットT2サブセット2

サブセット1:K:K:K

:K:K:K

ViewpointクラスK

Tree 1 Tree 2 Tree N2

・・・

Tree 1 Tree 2 Tree N2

・・・

Tree 1 Tree 2 Tree N2

・・・

74

Page 75: Random Forestsとその応用

2段階目: Keypointの分類結果

提案手法:38/45 (84%)Randomized Trees: 5/7 (71%)

75

Page 76: Random Forestsとその応用

キーポイントマッチング結果の比較

SIFT:0/1 (0%)

RTs :1/4 (25%) 2段階RTs:23/26 (88%)

ASIFT:276/276 (100%)

76

Page 77: Random Forestsとその応用

キーポイントマッチング手法の比較

95

90

85

80

75

10 100 1000 10000 100000

処理時間 [ms]

マッチング精度 [%]

2段階RTs ASIFT

SURF

RTs

SIFT

100

70

RFs

キーポイントマッチング(全探索)を決定木分類の問題として解く →高性能化と高速化を同時に実現

77

Page 78: Random Forestsとその応用

2段階Random Forestsによるキーポイントマッチング

78

Page 79: Random Forestsとその応用

2. 学習を用いたキーポイントマッチングの高速化 - Random Forestsを用いたキーポイントマッチング - 2段階Random Forestsによる高精度化 - Ferns

79

Page 80: Random Forestsとその応用

Random Ferns [Özuysal et al.,2010]

• キーポイント識別に特化させたRandom Forests ‒ 決定木のメモリ容量を削減 ‒ 同じ階層で共通の分岐関数を使用→ 各分岐関数の出力でリーフノードを表現可能

80

Ferns (シダ植物)

f0

f1 f2

f3 f4 f5 f6

f0

f1 f1

f2 f2 f2 f2

f0

f1

f2

Page 81: Random Forestsとその応用

Random Fernsの構築1

• 分岐関数の出力パターンからクラスの頻度分布を作成 ‒ 分岐関数はランダムで決定

81カテゴリciの学習画像

0

1

0

0 1

1

0

1

1

0

1

1 (011)2 = 3

(101)2 = 5

(010)2 = 2

(011)2 = 3

Fern

カテゴリciの頻度分布0 1 2 3 4 5 6

Page 82: Random Forestsとその応用

Random Fernsの構築2

• 分岐関数の出力パターンからクラスの頻度分布を作成

82

・・・

・・・

・・・

・・・

Ferns

Fern 1

Fern 2

Fern T

クラスc1 クラスc2 クラスc3

0 1 2 3 4 5 6

0 1 2 3 4 5 6

0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

Page 83: Random Forestsとその応用

Random Fernsの識別

• 各クラス毎に各Fernの頻度を総積して分類

83

・・・

Ferns

未知入力

(001)2

(101)2

(010)2

1

5

2

最終結果:

クラスc1 クラスc2 クラスc3

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

… ……

Page 84: Random Forestsとその応用

まとめ: キーポイントマッチング

• 学習を用いたキーポイントマッチングの高速化 ‒ Random Forestsを用いたキーポイントマッチング • SIFTベースの手法より高速・高精度化

‒ 2段階Random Forestsによる高精度化 • Viewpontに分けてから分類

‒ Ferns • Random Forestsの軽量化

84

Page 85: Random Forestsとその応用

85

3. Random Forestsを用いた物体検出 - Hough Forests - 事例ベースのRandom Forests

Page 86: Random Forestsとその応用

Hough Forests [Gall et al., 2011]

• Random Forestsモデルの物体検出器

• アイデア ‒ 局所パッチを用いた投票により物体重心を推定

• メリット ‒ 部分的な遮蔽があっても検出可能

• デメリット ‒ スケール変化に対応できない • 入力画像のスケールを変化させて対応

86

Page 87: Random Forestsとその応用

学習サンプル

• 学習用画像からパッチを抽出 ‒ 検出対象を含むパッチ:ポジティブサンプル • 物体中心とのオフセットベクトル:di

‒ 背景領域のパッチ:ネガティブサンプル • オフセットベクトルなし

87

ポジティブ ネガティブ

オフセットベクトル学習用画像

重心 切り出し

学習サンプル

Page 88: Random Forestsとその応用

Hough Forestsの分岐関数

88

• 分岐関数はパッチ内の輝度差を比較 ‒ 輝度差がしきい値以下の場合は左, それ以外は右に分岐

- > Th

右に分岐分岐ノード

Page 89: Random Forestsとその応用

分岐関数の決定方法

• 評価関数の値が最小の候補を分岐関数に決定

• 2つの評価関数を階層とサンプル数に応じて選択 ‒ クラスラベルのエントロピー

‒ オフセットベクトルの分散の値

89

数式

S(v) =

!left i ∈ In|fj(vi) < tjright otherwise

(1)

S(v) =

!Il i ∈ In|fj(vi) < tjIr In\Il

(2)

∆E (3)

Il = i ∈ In|fj(vi) < tj (4)

Ir = In\Il (5)

∆E = E(In) − |Il||In|

E(Il) −|Ir||In|

E(Ir) (6)

E(I) = −N"

n=1

Pnlog2Pn (7)

p(C = P |S) =1T

T"

t=1

SPt

SPt + SN

t

(8)

U1(A) = |A|(−c · logc − (1 − c) · log(1 − c)) (9)

U2(A) ="

i:ci=1

(di − dA)2 (10)

argmink

(U⋆({pi|tk(Ii) = 0) + U⋆({pi|tk(Ii) = 0)) (11)

1

数式

S(v) =

!left i ∈ In|fj(vi) < tjright otherwise

(1)

S(v) =

!Il i ∈ In|fj(vi) < tjIr In\Il

(2)

∆E (3)

Il = i ∈ In|fj(vi) < tj (4)

Ir = In\Il (5)

∆E = E(In) − |Il||In|

E(Il) −|Ir||In|

E(Ir) (6)

E(I) = −N"

n=1

Pnlog2Pn (7)

p(C = P |S) =1T

T"

t=1

SPt

SPt + SN

t

(8)

U1(A) = |A|(−c · logc − (1 − c) · log(1 − c)) (9)

U2(A) ="

i:ci=1

(di − dA)2 (10)

argmink

(U⋆({pi|tk(Ii) = 0) + U⋆({pi|tk(Ii) = 0)) (11)

1

A : パッチ集合c : Aのポジティブクラスの確率

tk : k番目の分岐関数の候補

FLAB Work Document April 26, 2013 6

Hough ImageV 歩行者検出結果

図 6: 投票処理を用いた歩行者検出

ここで dAはオフセットベクトル diの平均値であるので,U2はオフセットベクトルの分散に相当する.2つの評価関数を用いて,各ノードの分岐関数は以下の手順で選択される.まず,式(2)の分岐関数のプール {tk}を生成する.そして,式 (10)を用いて背景パッチと物体パッチの不確実性が最小となる分岐関数を選択する.

argmink

(U⋆({pi|tk(Ii) = 0) + U⋆({pi|tk(Ii) = 0)) (10)

ここで,⋆は 1か 2のいずれかをランダムに選択することを表している.しかし,入力されるパッチ集合に含まれる背景パッチの数があまりに少ない場合,オフセットの不確実性が最小となるように分岐関数を選択するため ⋆には 2が適用される.また,⋆に 1と 2を交互に選択することで,末端ノードでは確実に双方の不確実性が減少していると考えられる.このように構築した木を用いてオブジェクトの検出を行う.識別HFによる物体検出では,入力画像に含まれる対象オブジェクトを投票処理により,重心を求めることでオブジェクトを検出することができる.第 1段階により検出された歩行者候補領域から抽出したパッチを各決定木に入力する.末端ノードに到達した,画像中のある位置 yのパッチ I(y)が画像中の異なる位置 xを中心としたオブジェクトに含まれる確率を式 (11)により算出して,木の本数 T で平均する.

p(E(x)|I(y); {Tt}Tt=1) =

1T

!p(E(x)|I(y); Tt) (11)

次に,異なるパッチからの投票を統合するため,図 6に示すように 2次元のHough ImageV に投票を行う.そして,式 (12)により近隣のパッチからの投票をピクセル位置 xごとに総和すると,図 6(a)に示すようになる.

V (x) =!

p(E(x)|I(y); {Tt}Tt=1) (12)

投票した結果から,mean shift等を用いて算出した極大値をその位置をオブジェクトの重心として図 6(b)のように歩行者を検出することができる.

: パッチ画像

dA : Aのオフセットベクトルの平均

pi :サンプル集合

argmink

(U�({pi|tk(Ii) = 0}) + U�({pi|tk(Ii) = 1}))左の子ノードに分岐したサンプル集合

右の子ノードに分岐したサンプル集合

Page 90: Random Forestsとその応用

末端ノードの作成

• 末端ノードに保存される情報 ‒ クラス確率 CL

‒ オフセットベクトル d

90

P Nオフセットベクトルクラス確率 CL

・・・・-75

-5075

50

0

0

到達したパッチ

物体中心

Page 91: Random Forestsとその応用

Hough Forestsの識別

• 入力画像からパッチを抽出 ‒ 各決定木に入力 ‒ 決定木の出力を尤度マップに投票 ‒ mean shift等を用いて物体重心を検出

91

尤度マップ 検出結果

Page 92: Random Forestsとその応用

事例ベースのRandom Forest [Dahang et al., 2012]

• アイデア ‒ テンプレートと未知入力サンプルの距離計算により左右に分岐 ‒ 学習により最適なテンプレートとしきい値を選択

• メリット ‒ 高速な識別 • DOT特徴を用いた類似度計算 → SSDによる高速な距離計算 • カスケード構造のRandom Forest → 探索空間の削減

92

Page 93: Random Forestsとその応用

第1段階  

歩行者候補領域

カスケード構造のRF による歩行者検出器

• 第1段階:Holistic RFにより歩行者候補領域を検出 ‒ Random Forestsと同じ学習アルゴリズムを使用

• 第2段階:Patch-based RF による歩行者検出 ‒ Hough Forestsと同じ学習アルゴリズムを使用

93

入力画像 第2段階  

歩行者検出結果

Page 94: Random Forestsとその応用

DOT特徴量 [Hinterstoisser et al., 2010]

• DOT(Dominant Orientation Templates)特徴を使用 ‒ 局所領域の離散的な勾配方向毎に勾配強度をバイナリコード化 • 最上位ビットは注目画素が垂直の場合1, それ以外は0

94

τ

11000 1 11

入力画像 セル 勾配方向ヒストグラム

バイナリ化

Page 95: Random Forestsとその応用

分岐関数の設計

• テンプレートとサンプルの距離計算により左右に分岐 ‒ Holistic RFとPatch-based RFで同じ分岐関数を使用

95

:左に分岐 :右に分岐分岐関数:

FLAB Work Document April 26, 2013 2

p(E(x)|I(y); {Tt}Tt=1) =

1T

!p(E(x)|I(y); Tt) (12)

V (x) =!

p(E(x)|I(y); {Tt}Tt=1) (13)

d

CL

"F (S, Ti) < τi

otherwise(14)

S : 未知サンプルTi : テンプレートτi : しきい値

検出ウィンドウ

テンプレート

テンプレートの バイナリコード

AND演算子

未知サンプルの バイナリコード

FLAB Work Document April 26, 2013 2

p(E(x)|I(y); {Tt}Tt=1) =

1T

!p(E(x)|I(y); Tt) (12)

V (x) =!

p(E(x)|I(y); {Tt}Tt=1) (13)

d

CL

"F (S, Ti) < τi

otherwise(14)

T

SNt

SPt

F (S, T ) =!

P Sd ∈S

P Td ∈T

δ(P sd ⊗ P T

d = 0)   d = 1, 2, · · · , n (15)

FLAB Work Document April 26, 2013 2

p(E(x)|I(y); {Tt}Tt=1) =

1T

!p(E(x)|I(y); Tt) (12)

V (x) =!

p(E(x)|I(y); {Tt}Tt=1) (13)

d

CL

"F (S, Ti) < τi

otherwise(14)

T

SNt

SPt

F (S, Ti) =!

P Sd ∈S

P Td ∈T

δ(P sd ⊗ P T

d = 0)   d = 1, 2, · · · , n (15)

PSd

P Td

PS1

P T1

PS2

P T2

PS3

P T3

PS55

P T55

=

n : セルの数

00010 0 00 ≠ 0δ( )

01010 0 10P2S

10110 1 00P2T

FLAB Work Document April 26, 2013 2

p(E(x)|I(y); {Tt}Tt=1) =

1T

!p(E(x)|I(y); Tt) (12)

V (x) =!

p(E(x)|I(y); {Tt}Tt=1) (13)

d

CL

"F (S, Ti) < τi

otherwise(14)

T

SNt

SPt

F (S, T ) =!

P Sd ∈S

P Td ∈T

δ(P sd ⊗ P T

d = 0)   d = 1, 2, · · · , n (15)

0

分岐ノード

Page 96: Random Forestsとその応用

歩行者検出の結果例

96

人が密集するような状況においても高精度に検出

[Dahang et al., 2012]

Page 97: Random Forestsとその応用

4. Random Forestsを用いた人体姿勢推定

97

Page 98: Random Forestsとその応用

Random Forestsによる人体姿勢推定 [Shotton2011]

• 一枚の距離画像から三次元人体姿勢推定を実現‒ 高速、高精度、低計算コスト ‒ 応用先:NUI (Natural User Interface)

98

出力:3次元間接位置(姿勢)入力:単一の距離画像

Page 99: Random Forestsとその応用

手法の流れ

1.深度画像から人体を検出(背景差分)2. 人体をパーツ分割 3. 関節の3次元位置を取得

99

Page 100: Random Forestsとその応用

アプローチ

1.人体パーツの学習データ‒ 様々な姿勢の人体深度データを人工的に生成

2. 人体パーツ識別・姿勢推定 ‒ 高速に計算可能な特徴量 ‒ Random Forest(マルチクラス識別器)による人体パーツ識別

100

Page 101: Random Forestsとその応用

CGによる人体データの生成

• CGにより生成する人体形状データ ‒ Autodesk MotionBuilder内の3Dメッシュデータを利用 • 15種類の素体データ

101

※ パーツの学習用に色分け済み

Autodesk MotionBuilder

Page 102: Random Forestsとその応用

人体モデルにモーションを付加

• モーションキャプチャデータ‒ mocap(CMU): http://mocap.cs.cmu.edu/ • 特定の運動時の各関節の角度データ • 100,000データ

102

Page 103: Random Forestsとその応用

学習データの自動生成

• 学習データの生成の流れ‒ Autodesk MotionBuilderより素体を選択 ‒ 素体の各関節にモーションキャプチャのデータを設定し,3Dメッシュを変形 • 色々なパラメータをランダムに設定

‒ 身長・幅・形状・カメラ姿勢・カメラノイズ・衣服・髪など

‒ 3Dメッシュをレンダリングし,デプスを取得

103

人体データ

モーションデータ

Autodesk MotionBuilder

学習データ

Page 104: Random Forestsとその応用

距離差に基づく特徴量

• 注目点周辺の2点間の距離値の差

104

������

����

�����

����

����� ������

:注目画素 :差分を求める選択した2点

θ1 :距離差が大きい(背景と体)θ2 :距離差が大きい(背景と腕)

θ1 : 距離差が小さい(頭と体)θ2 : 距離差が小さい(腕や足等の細い部位)

������

����

�����

����

����� ������

Page 105: Random Forestsとその応用

Random Forests による識別器の学習

• 生成した人体パーツ画像データを学習‒ 学習の入力:距離画像と注目画素 + 正解人体パーツラベル

105

���1���

学習サンプル

深度画像 パーツのラベル

各ノードでθとτを決定

31 body parts: LU /RU /LW /RW head, neck, L /R shoulder, LU /RU /LW /RW arm, L /R elbow, L /R wrist, L /R hand, LU /RU /LW /RW torso, LU /RU /LW /RW leg, L /R knee, L/R ankle, L /R foot (Left, Right, Upper, loWer)

画素単位で識別

Page 106: Random Forestsとその応用

各画素毎の人体パーツ推定結果

Figure 9. Example results from the Ganapathi et al. test set. This test set contains one actor from a low fixed camera viewpoint (whichmakes the actor appear to be leaning backwards). Our system can accurately localize body joints despite being designed for a differentdepth camera. Quantitative comparison in main paper.

Figure 9. Example results from the Ganapathi et al. test set. This test set contains one actor from a low fixed camera viewpoint (whichmakes the actor appear to be leaning backwards). Our system can accurately localize body joints despite being designed for a differentdepth camera. Quantitative comparison in main paper.

Figure 9. Example results from the Ganapathi et al. test set. This test set contains one actor from a low fixed camera viewpoint (whichmakes the actor appear to be leaning backwards). Our system can accurately localize body joints despite being designed for a differentdepth camera. Quantitative comparison in main paper.

Figure 9. Example results from the Ganapathi et al. test set. This test set contains one actor from a low fixed camera viewpoint (whichmakes the actor appear to be leaning backwards). Our system can accurately localize body joints despite being designed for a differentdepth camera. Quantitative comparison in main paper.

106

Page 107: Random Forestsとその応用

関節の3次元位置推定

• 各パーツごとに関節の3次元位置を推定‒ 密度推定を行い,最頻値を推定 • ミーンシフトベースの手法を利用

107

カーネル密度推定(パーツクラスcに対する)

:3次元空間中の位置(画像上の位置 に対応)

Page 108: Random Forestsとその応用

距離画像からの人体姿勢推定

Xbox 360 GPU上で5ms/frame以下 (200FPS) で動作

108

Page 109: Random Forestsとその応用

5. Regression Forests - 回帰分析への応用 -

109

Page 110: Random Forestsとその応用

• Regression Forests • 学習アルゴリズム ‒ 回帰木の作成 ‒ 分岐ノードの決定

• 回帰 ‒ 予測の統合

• 最小二乗法との比較 ‒ UCI Machine Learning Repository を用いた比較

• CV分野への応用

110

Page 111: Random Forestsとその応用

Random ForestsとRegression Forests

• Random Forests : クラス分類問題 ‒ 決定木:クラス確率を保持 ‒ 入力 : 連続変数 ‒ 出力 : カテゴリごとの確率

• Regression Forests : 回帰問題 ‒ 回帰木:回帰係数を保持 ‒ 入力 : 連続変数 ‒ 出力 : 連続変数

111

Random Forests Regression Forests

Page 112: Random Forestsとその応用

112

回帰分析

?

x

y

学習サンプル未知入力サンプル

y

u

x

?

線形モデル

y = a+ bx

y = a+ bx+ cu

回帰直線 回帰平面

出力

入力

出力

入力

• 入力変数から出力変数の値を予測 • 線形,非線形などの回帰モデル ‒ 回帰係数を最小二乗法などで求める問題

Page 113: Random Forestsとその応用

Regression Forestsとは

• 目的 ‒ 高精度な回帰分析 ‒ 線形,非線形な回帰

• メリット ‒ 予測モデルにより様々な回帰分析が可能

• デメリット ‒ 最小二乗法による線形回帰より学習に時間が必要

113

Page 114: Random Forestsとその応用

学習アルゴリズム

• 前処理 ‒ サンプル集合をサブセットに分割

• 回帰木の作成 ‒ 分岐ノードの学習 ‒ 末端ノードの作成 ‒ 予測モデル

114

Page 115: Random Forestsとその応用

前処理

• Random Forestsと同様にサブセットを作成 ‒ ランダムサンプリングによって任意の数のサンプルを抽出 ‒ サブセット間の重複は許容

115

サブセット S1 サブセット S2 サブセット ST

サンプル集合 S

Page 116: Random Forestsとその応用

回帰木の作成

• サブセットを用いて回帰木を作成 ‒ 分岐ノード • サンプルの特徴量としきい値の比較しサンプルを左右に分岐

‒ 末端ノード • 辿り着いた学習サンプルを回帰分析した結果を保存

116

分岐ノード

末端ノード

Page 117: Random Forestsとその応用

• ランダムに特徴次元としきい値を選択

• 目的関数を最大にする特徴次元としきい値を選択

分岐ノードの決定過程

117

Ij =�

(x,y)�Sj

(y � yj)2 ��

i=L,R

��

(x,y)�Sij

(y � yj)2�

現在のノード における分散

目的関数

子ノードの和

子ノード の分散j jL, jR

y

x

y

出力

入力

1 2 3

jLjR

j

Sj

SLj

SRj

Page 118: Random Forestsとその応用

分岐ノード決定過程1

• 候補1の目的関数の評価値を算出 ‒ 分割したサンプル集合を用いて についての分散を算出

118

候補1により サンプルを分割

�2L = 6.0

�2R = 12.0

y

L Rx

y

出力

入力

1 2 3

x

y 1

Page 119: Random Forestsとその応用

分岐ノード決定過程2

• 候補2の目的関数の評価値を算出 ‒ 分割したサンプル集合を用いて についての分散を算出

119

�2L = 11.3

y

候補2により サンプルを分割

�2R = 12.0

L Rx

y

出力

入力

1 2 3 y 2

x

Page 120: Random Forestsとその応用

分岐ノード決定過程3

• 候補3の目的関数の評価値を算出 ‒ 分割したサンプル集合を用いて についての分散を算出

120

�2L = 20.1

�2R = 0.6

y

L Rx

y

出力

入力

1 2 3

x

y 3

候補3により サンプルを分割

Page 121: Random Forestsとその応用

31

分岐ノード決定過程4

• 目的関数が最大となる分岐関数に決定

121

→末端ノードを作成する条件を満たすまで分岐を繰り返す

I1 = 35.8� (6.0 + 12.0) = 17.8

I2 = 35.8� (11.3 + 0.8) = 23.7

I3 = 35.8� (20.1 + 0.6) = 15.1x

y

出力

入力

1 2 3

Page 122: Random Forestsとその応用

末端ノードの作成

• 一定の条件に達した場合に末端ノードを作成 ‒ 深さ,到達したサンプル数....etc.

• 到達したサンプルを用いて回帰分析 ‒ 回帰係数を保存

122

保存

x

y

出力

入力

Page 123: Random Forestsとその応用

回帰

• 未知入力サンプルを各回帰木に入力 ‒ 辿り着いた末端ノードの回帰係数を用いて予測値を出力

123

y =1T

T�

t=1

yt→各回帰木の出力を合成

・・・

y1 y2

yT

Page 124: Random Forestsとその応用

回帰木の統合(tree1)

• 平均モデルを用いたRegression Forestsによる回帰

124

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sample

tree1

Page 125: Random Forestsとその応用

回帰木の統合(tree2)

• 平均モデルを用いたRegression Forestsによる回帰

125

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sample

tree2

Page 126: Random Forestsとその応用

回帰木の統合(tree3)

• 平均モデルを用いたRegression Forestsによる回帰

126

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sample

tree3

Page 127: Random Forestsとその応用

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sample

tree4

回帰木の統合(tree4)

• 平均モデルを用いたRegression Forestsによる回帰

127

Page 128: Random Forestsとその応用

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sample

tree5

回帰木の統合(tree5)

• 平均モデルを用いたRegression Forestsによる回帰

128

Page 129: Random Forestsとその応用

100

150

200

250

300

0 50 100 150 200 250 300 350 400

Y

X

train sampleoutputtree1tree2tree3tree4tree5

回帰木の統合(Regression Forests)

• 平均モデルを用いたRegression Forestsによる回帰

129

Page 130: Random Forestsとその応用

回帰モデル

• 末端ノードの回帰モデルは自由に設計 ‒ 平均 • サンプル集合の目的変数の平均値を予測とする

‒ 線形回帰 • 最小二乗法などを用いて線形回帰

‒ 確率的線形回帰 • 線形回帰+分散による信頼性の算出

130

x

y

平均x

y

線形x

y

確率的線形計算コスト 小 大回帰精度 低 高

Page 131: Random Forestsとその応用

回帰モデル:平均モデル

131

0

50

100

150

200

250

300

350

400

0 50 100 150 200 250 300 350 400

Y

X

outputtrain sample

• 木の数:5,木の深さ:10

Page 132: Random Forestsとその応用

0

50

100

150

200

250

300

350

400

0 50 100 150 200 250 300 350 400

train sampleoutput

Y

X

回帰モデル:線形モデル

132

• 木の数:5,木の深さ:2

Page 133: Random Forestsとその応用

回帰モデル:確率的線形モデル

133

• 木の数:10,木の深さ:2

0

50

100

150

200

250

300

350

400

0 50 100 150 200 250 300 350 400

train sampleoutput

kukan +kukan -

Y

X

→サンプルの分散に基づき回帰の信頼性を表現

Page 134: Random Forestsとその応用

実データを用いた最小二乗法との比較

• 最小二乗法とRegression Forestsの比較 • UCI Machine Learning Repositoryのデータセット ‒ 機械学習のベンチマークデータセット ‒ URL : http://archive.ics.uci.edu/ml/ ‒ 回帰,クラス分類問題などを扱う ‒ Dataset : Concrete Compressive Strength Data Set • 目的変数:コンクリートの強度(1次元) • 従属変数:8次元の実数 • サンプル数:1030

134

Page 135: Random Forestsとその応用

Regression Forestsと最小二乗法の比較

• 木の学習パラメータ ‒ 木の深さ : 5, 10 ‒ 木の本数 : 5. 10 ‒ サブセットのサイズ : 1.0

• 残差の2乗和を比較

135

→残差を大幅に減少

Page 136: Random Forestsとその応用

人体の向き推定

• 10度毎に学習し5度毎に評価 • 平均モデル ‒ 5クラスに分けてRandom Forestを学習 ‒ 末端ノードはラベルの平均値を保存

• 線形モデル ‒ Regression Forestにより学習 ‒ 末端ノードは最小二乗法による回帰予測を保存

136-90° -45° 0° 45° 90°

Page 137: Random Forestsとその応用

平均モデルと線形モデルの推定結果例

• 人体姿勢推定 ‒ 10度刻みの角度で学習

137

0.00

2.00

4.00

6.00

8.00

10.00

12.00

14.00

16.00

-100 -80 -60 -40 -20 0 20 40 60 80 100 人体の向き [deg]

平均誤差[deg]

Page 138: Random Forestsとその応用

CV分野への応用1

• Conditional Regression Forestsによる顔向き推定と顔特徴点の推定 [Dantone, M. et al., 2012]

‒ 入力:パッチ(Haar-like特徴:領域間の輝度差) ‒ 出力:顔向き,器官位置

138

Real-time Facial Feature Detection using Conditional Regression Forests

Matthias Dantone1 Juergen Gall1,2 Gabriele Fanelli1 Luc Van Gool1,31ETH Zurich, Switzerland 2MPI for Intelligent Systems, Germany 3KU Leuven, Belgium{dantone,fanelli}@vision.ee.ethz.ch [email protected] [email protected]

Abstract

Although facial feature detection from 2D images is awell-studied field, there is a lack of real-time methods thatestimate feature points even on low quality images. Here wepropose conditional regression forest for this task. Whileregression forest learn the relations between facial imagepatches and the location of feature points from the entireset of faces, conditional regression forest learn the relationsconditional to global face properties. In our experiments,we use the head pose as a global property and demonstratethat conditional regression forests outperform regressionforests for facial feature detection. We have evaluated themethod on the challenging Labeled Faces in the Wild [20]database where close-to-human accuracy is achieved whileprocessing images in real-time.

1. IntroductionDue to its relevance for many applications like human

computer interaction or face analysis, facial feature pointdetection is a very active area in computer vision [1, 3,24, 25, 29]. Recent state-of-the-art methods like [3] havereported impressive results where localization accuracy ofhuman annotators has been achieved on images of mediumquality. However, most of the available methods do notachieve real-time performance which is a requirement formany applications. Furthermore, low quality images stillchallenge state-of-the-art algorithms.

In recent years, regression forests [4] have proven to be aversatile tool for solving challenging computer vision tasksefficiently. In this domain, regression forests learn a map-ping from local image or depth patches to a probability overthe parameter space, e.g., the 2D position or the 3D orien-tation of the head. While related Hough forests [16] detectobjects in 2D images efficiently, real-time methods for poseestimation [12, 17] rely on depth data and an abundance ofsynthetic training data.

In this work, we present a method based on regressionforests that detects 2D facial feature points in real-time asexemplified by Fig. 1. Since regression forests learn the

Figure 1. Our approach estimates facial feature points from 2Dimages in real-time.

spatial relations between image patches and facial featuresfrom the complete training set and average the spatial dis-tributions over all trees in the forest, the forests tend to in-troduce a bias to the mean face. This is very problematicfor facial feature detection since subtle deformations affectonly the image appearance in the neighborhood of a specificfeature point. In order to steer the impact of patches close toa facial feature, which adapt better to local deformations butare more sensitive to occlusions, and more distant patchesthat favor the mean face, we introduce an objective functionthat allows to find a good trade-off.

Another contribution of this work is the introduction ofconditional regression forests. In general, regression forestsaim to learn the probability over the parameter space givena face image from the entire training set, where each treeis trained on a randomly sub-sampled training set to avoidover-fitting. Conditional regression forests aim to learn sev-eral conditional probabilities over the parameter space in-stead. The motivation is that conditional probabilities areeasier to learn since the trees do not have to deal with allfacial variations in appearance and shape. Since some vari-

1

Page 139: Random Forestsとその応用

CV分野への応用2

• Regression Forestsによる人体姿勢推定[Taylor2012]

‒ Regression Forestによるパーツ座標の回帰推定 ‒ 回帰結果による対応点群を用いた人体モデルの当てはめ

139

Overview

inferred dense correspondences

testimages

regression forest

energyfunction

optim

izatio

n of

mod

el p

aram

eter

s 𝜃

final optimized poses

front right top

trainingimages

Regression Forestによるパーツ座標の回帰推定

回帰結果への人体モデルの当てはめ

Page 140: Random Forestsとその応用

Regression Forestによる人体姿勢推定

• パーツ識別ではなく、座標の回帰推定問題へ‒ 人体座標を連続値で表現して回帰木を構築

140

Texture is mapped across body shapes and poses

From Body Parts to Dense Correspondences

increasing number of parts

classification regression

The  “Vitruvian  Manifold”Body Parts

Random Forestにおける教師ラベル Regression Forestにおける教師信号

Page 141: Random Forestsとその応用

Regression Forestによる人体姿勢推定

• 距離画像の各画素毎に回帰による推定

141

Inferring Correspondences入力:距離画像と注目画素(u.v)

出力:注目画素(u,v)の人体座標

Page 142: Random Forestsとその応用

Regression Forestによる人体姿勢推定

• 回帰結果と人体モデルの対応点群Uから姿勢θを推定

142

infer correspondences 𝑈

optimize parameters

min𝐸(𝜃, 𝑈)

1. 距離画像 2. 回帰推定

3. 人体モデルとの対応点群U 4. 姿勢θの推定

Page 143: Random Forestsとその応用

Regression Forestによる人体姿勢推定

143

http://www.cs.toronto.edu/~jtaylor/papers/cvpr2012-supplementary_materials-video.mp4

Page 144: Random Forestsとその応用

6. Random Forestsの他の問題設定への適用 - Density Forests - 密度推定 - - Semi-supervised Forests - 半教師付き学習 -

144

Page 145: Random Forestsとその応用

Density Forestsとは

• 目的 ‒ Forestモデルを用いたサンプル集合の密度推定

• メリット ‒ 複雑な問題に対し柔軟な密度推定が可能

145

Page 146: Random Forestsとその応用

Random ForestsとDensity Forests

• Random Forests : クラス分類問題 ‒ 決定木:クラス確率を保持 ‒ 入力 : 連続変数 ‒ 出力 : カテゴリごとの確率

• Density Forests : 密度推定問題 ‒ 密度木:密度分布を保持 ‒ 入力 : 連続変数 ‒ 出力 : 推定密度

146

Random Forests Density Forests

Page 147: Random Forestsとその応用

密度木の作成

• サンプル集合を用いて密度木を作成 ‒ 分岐ノード • サンプルの特徴量としきい値の比較しサンプルを左右に分岐

‒ 末端ノード • 辿り着いた学習サンプル集合の密度分布を保存

147

分岐ノード

末端ノード

Page 148: Random Forestsとその応用

• ランダムに特徴次元としきい値の候補を選択

• 候補の中から目的関数を最大にするものを選択 ‒ ラベルがないため正規分布のエントロピーを利用

分岐ノードの学習

148

目的関数 Ij = log(|�(Sj)|)��

i�{L,R}

|Sij |

|Sj | log(|�(Sij)|)

SRj

Sj

SLj

1

2

j

jL jR

親のノード の正規分布のエントロピー 子ノード の正規分布のエントロピー

x1

x2

j jL, jR

Page 149: Random Forestsとその応用

1

2

分岐ノード決定過程1

• 候補1の目的関数の評価値を算出

149

候補1により サンプルを分割

L R

1

I1 = 5.67 − 1.25 +1.30( ) = 3.12

Sj SLj SR

j

x1

x2

x1

x2

Page 150: Random Forestsとその応用

1

2

分岐ノード決定過程2

• 候補2の目的関数の評価値を算出

150

候補2により サンプルを分割

L

R

2

Sj

SRj

SLj

x1

x2

x1

x2

I2 = 5.67 − 2.35 + 2.13( ) =1.19

Page 151: Random Forestsとその応用

分岐ノード決定過程3

• 目的関数が最大となる分岐関数に決定 → 候補1の方が情報利得が大きくなる

151

→末端ノードを作成する条件を満たすまで分岐を繰り返す€

I1 = 5.67 − 1.25 +1.30( ) = 3.12

I2 = 5.67 − 2.35 + 2.13( ) =1.19

1

2

Sj

x1

x2

Page 152: Random Forestsとその応用

末端ノードの作成

• 終了条件(深さ,到達したサンプル数....etc. ) • 到達したサンプル集合を用いて密度分布を算出 ‒ すべての末端ノードの密度分布情報を保存

152

µ, Λ保存

:密度分布

µ, Λ保存µ, Λ保存 µ, Λ保存

:サンプル

Page 153: Random Forestsとその応用

• 各ノードに到達した学習サンプルはひとつの多変量正規分布        にまとめられる ‒ 正規分布の重なりを考慮し分配関数 を用いて正規化

‒ 高次元な の計算は困難であるため近似を行う

分配関数

153一本の木から得られる密度分布

: 積分の間隔

: 各末端ノードに到達したサンプルの割合: 各末端ノードに到達した各次元の平均値: 各末端ノードの共分散行列

: 入力サンプル

間隔を狭くする事で近似はより正確になる

Page 154: Random Forestsとその応用

アンサンブルモデル

• サンプル集合を密度木に入力 ‒ 辿り着いた末端ノードの密度分布を用いて推定密度を出力

154

pT (v)p2(v)p1(v)

tree 1 tree 2 tree T

→各密度木の出力を合成 p(v) =1T

T�

t

pt(v)

+

++

/T

・・・

Average

各木の出力:

サンプルの割合

分配関数 末端ノードの正規分布

Page 155: Random Forestsとその応用

Density Forests による密度推定結果

155

入力データ

Den

sity

For

ests

Page 156: Random Forestsとその応用

• 個々の木の出力では特徴をとらえきれてないが木の出力を合成することで滑らかな密度推定が可能

アンサンブルモデルの効果

156

tree 1 tree 2 tree T€

+

++

/T =

各treeの出力 forestsの出力

Page 157: Random Forestsとその応用

6. Random Forestsの他の問題設定への適用 - Density Forests - 密度推定 - - Semi-supervised Forests - 半教師付き学習 -

157

Page 158: Random Forestsとその応用

Semi-supervised とは

• supervised:教師あり学習 ‒ すべてのサンプルにラベルがある

• unsupervised:教師なし学習 ‒ すべてのサンプルにラベルが無い

• semi-supervised:半教師あり学習 ‒ ラベル付きの小規模なサンプル集合とラベル無しの大規模なサンプル集合が混合

‒ 代表的な手法 • トランスダクティブサポートベクターマシン(TSVM)

158

Page 159: Random Forestsとその応用

• 識別性能を向上するためラベル付けされていないサンプルを有効に活用 ‒ トランスダクティブ学習を行う

Semi-supervised learning

159

部分的にラベル付けされたサンプル ラベルの伝播

:ラベル付きサンプル

:ラベル無しサンプル

識別境界

vl

vu

Page 160: Random Forestsとその応用

Semi-supervised Forests

• 教師あり学習と密度推定の両方の考え方を利用 ‒ ラベル付きサンプルの情報利得とラベル付き,ラベル無しサンプル集合の正規分布のエントロピーにより分割

‒ ラベルなしサンプルにラベルを伝播 • クラス確率を定義

160

クラス確率 密度

+Random Forests Density Forests

Page 161: Random Forestsとその応用

分岐ノードの選択

• 目的関数を最大とする組み合わせ情報利得により学習サンプルの分類と高密度領域を分割

161

教師あり:

教師なし:

従来の分類木のようにクラス確率のエントロピーにより算出

密度推定と同様に正規分布のエントロピーにより算出

ラベル付きデータのみを用いる

ラベル付き,ラベル無し 両方のデータを用いる

:ユーザーで定義される変数間の相対的な重み目的関数:

Page 162: Random Forestsとその応用

• 目的関数を最大とする組み合わせ情報利得により学習サンプルの分類と高密度領域を分割

分岐ノードの選択

162

→ラベル付きサンプルのクラス確率のエントロピーが小さく 全てのサンプルの正規分布のエントロピーが小さいものが選択される

:ユーザーで定義される変数間の相対的な重み目的関数:

Page 163: Random Forestsとその応用

Semi-supervised Forestsの構築

• 末端ノードに各次元の平均値と共分散行列を保存

163

µ, Λ保存µ, Λ保存

Tree 1 Tree T

学習サンプル

...

Page 164: Random Forestsとその応用

ラベルの伝播

• ラベル無しサンプルとの測地線距離が最小となるラベル付きサンプルのラベルを伝播

164

:クラス

:測地線距離

測地線距離 :測地線パス:測地線パスの長さ:すべての測地線パス

:初期点,終了点

局所距離(マハラノビス距離)

:各ポイントの距離

:  によって末端ノードの共分散行列

Page 165: Random Forestsとその応用

• サンプルにラベルを伝播した結果を用いて末端ノードにクラス確率    を定義 ‒ 帰納的にforestの構築を行うため新しい分類器の学習は不要

帰納

165

Tree 1 Tree T

...

Page 166: Random Forestsとその応用

Semi-supervised ForestsとSVM,TSVMの比較

166

Semi-Supervised Forest

SVM TSVM入力データ

[Criminisi et al., 2011]

Page 167: Random Forestsとその応用

Semi-supervised Forests による分類結果

167

[Criminisi et al., 2011]

入力データ 深さD=6 深さD=10

ラベル付きデータ数

4個 (各クラス1個)

ラベル付きデータ数

8個 (各クラス2個)

Page 168: Random Forestsとその応用

チュートリアル資料:Random Forests[Criminisi et al., 2011]

• Classification, Regression, Density Estimation, Manifold Learning and Semi-Supervised Learning

168

チュートリアル: http://research.microsoft.com/en-us/groups/vision/decisionforests.aspx

Page 169: Random Forestsとその応用

参考文献1

•1. Random Forests - [Breiman, 2001] L. Breiman, "Random Forests.", Machine Learning 45 (1): 5‒32, 2001.

- [Lepetit et al., 2006] V. Lepetit and P. Fua, “Keypoint Recognition using Randomized Trees”, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 28, Nr. 9, pp. 1465-1479, 2006.

- [Shotton et al., 2008] J. Shotton, M. Johnson, R. Cipolla, “Semantic Texton Forests for Image Categorization and Segmentation.”, In Proc. IEEE CVPR 2008.

- [Amit & Geman, 1997] Y. Amit and D. Geman Y, “Shape Quantization and Recognition with Randomized Trees”, Neural Computation, vol. 9, pp. 1545-1588, 1996

- [Moosmann et al., 2006] F. Moosmann, B. Triggs, and F. Jurie, “Fast Discriminative Visual Codebooks using Randomized Clustering Forests.”, In NIPS, 2006.

- [山下 et al., 2010] 山下隆義, 山内悠嗣, 藤吉弘亘, "Boosted Randomized Trees による人物検出と行動の同時認識", 第13回画像の認識・理解シンポジウム(MIRU2010), 2010.

- [Geurts et al., 2006] P. Gurts, D. Ernst, and L. Wehenkel, “Extremely Randomized Trees”, Machine Learning, vol. 63, issue 1, pp. 3-42, 2006. 169

Page 170: Random Forestsとその応用

参考文献1

•2. 学習を用いたキーポイントマッチングの高速化 - [西村 et al., 2010] 西村孝, 清水彰一, 藤吉弘亘, "2段階のRandomized Treesを用いたキーポイントの分類", 第13回画像の認識・理解シンポジウム(MIRU2010), 2010.

- [Özuysal et al.,2010] M. Özuysal, M. Calonder, V. Lepetit, P. Fua, “Fast Keypoint Recognition using Random Ferns” IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 32, Nr. 3, pp. 448 - 461, 2010.

•3. Random Forestsを用いた物体検出 - [Gall et al., 2011] J.Gall, A.Yao, N.Razavi, L.Van Gool, and V. Lempitsky, “Hough forests for object detection, tracking and action recognition”, IEEE Transactions on Pattern Analysis and Machine Itelligence, vol. 33, no. 11, pp. 2188-2202, 2011.

- [Dahang et al., 2012] Tang Danhang, Yang Liu, and Tae-Kyun Kim. “Fast Pedestrian Detection by Cascaded Random Forest with Dominant Orientation Templates”, BMVC, pp. 58.1-58.11, 2012

- [Hinterstoisser et al., 2010] S.Hinterstoisser, V. Lepetit, S. llic, P. Fua, and N. Navab, “Dominant Orientation Templates for Real-Time Detection of Texture-Less Objects”, IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 2010. 170

Page 171: Random Forestsとその応用

参考文献3

•4. Random Forestsを用いた人体姿勢推定 - [Shotton et al., 2011] Jamie Shotton, Andrew Fitzgibbon, Mat Cook, Toby Sharp, Mark Finocchio, Richard Moore, Alex Kipman, Andrew Blake,”Real-Time Human Pose Recognition in Parts from Single Depth Images”,Computer Vision and Pattern Recognition,vol.2,pp.1297-1304,2011.

- [Criminisi et al., 2011] A. Criminisi, J. Shotton, and E. Konukoglu, Decision Forests for Classification, Regression, Density Estimation, Manifold Learning and Semi-Supervised Learning, no. MSR-TR-2011-114, 28 October 2011.

•5. Regression Forests - [Girshick R. et al., 2011] Girshick R., Shotton J., Kohli P., Criminisi A., and Fitzgibbon A., “Efficient regression of general-activity human poses from depth images”, Computer Vision (ICCV), 2011 IEEE International Conference on, 415 -422, 2011.

- [Dantone, M. et al., 2012] Dantone M., Gall J., Fanelli G., and Van Gool L., “Real-time facial feature detection using conditional regression forests”, Computer Vision and Pattern Recognition (CVPR), 2012 IEEE Conference on, 2578 -2585, 2012. 171

Page 172: Random Forestsとその応用

プログラム解説

• プログラム構成 ‒ main_training.cpp (学習のメイン関数) ‒ main_evaluate.cpp (識別のメイン関数) ‒ rts_forest.cpp (RFの生成・走査に関する処理関数) ‒ rts_tree.cpp (決定木の生成・走査に関する処理関数) ‒ rts_forest.hpp (決定木のパラメータに関するヘッダ) ‒ rts_tree.hpp (決定木の生成・走査に関するヘッダ) ‒ rts_feature.hpp (特徴量を格納するクラスが書かれたヘッダ) ‒ rts_node.hpp (各ノードの情報を格納するクラス) ‒ rts_sample.hpp (各サンプルの特徴ベクトルとラベルを格納するクラス)

172

Page 173: Random Forestsとその応用

データ構造

• サンプル ‒ 特徴ベクトル • Feature feature_vec(vector型float配列);

‒ 教師信号 • int label;

• ノード ‒ int feature_id; // feature ID ‒ float threshold; // threshold ‒ float *distribution; // distribution histogram ‒ Node *lChild; // left Child node ‒ Node *rChild; // right Child node

173

Page 174: Random Forestsとその応用

プログラム解説

174

rts_forest rts_tree・サブセットの生成・決定木の生成・末端ノードの生成・決定木の情報の保存

main_training・サンプル入力・Forest の学習

・分岐関数の選択・末端ノードの生成

・ノードの書き出し

サブセット決定木のパラメータ

- 教師信号の投票-出現確率の正規化

サンプル集合

rts_forest rts_tree・決定木による識別・決定木の出力を統合

main_evaluate・Forest の読込み・サンプルの読込み・識別

・決定木の走査

学習

識別サンプル

サンプル集合

末端ノードのクラス確率

特徴ベクトル

サンプル集合決定木のパラメータ

Forest 全体のクラス確率

Page 175: Random Forestsとその応用

rts_forest.cpp

175

Learn - サンプルから Forest を生成する関数 - 引数 : 決定木のパラメータとサンプル集合 - tree の BuildTree, BuildHistgramを呼び出し

EstimateClass - 未知入力サンプルの識別を行う関数 - 引数 : 識別サンプル (特徴ベクトル ) - tree の Traversal を呼び出し

Save - Forest を保存する関数 - 引数 : ファイル名 - tree の Save を呼び出し

Load - Forest を読み込む関数 - 引数 : ファイル名 - tree の Load を呼び出し

Page 176: Random Forestsとその応用

rts_tree.cpp

176

BuildTree - 再帰によりノードを生成する関数 - 引数 : 決定木のパラメータとサンプル集合、ラベルに対する重み - 各ノードの分岐関数を選択する

BuildHistgrams - 生成した決定木の末端ノードを生成する関数 - 引数 : サンプル集合、ラベルに対する重み - clearHistgrams, voteHistograms, normalizeHistogra を呼び出し

clearHistograms - 末端ノードのヒストグラムを初期化する関数 - 引数 : ノードのアドレス

voteHistograms - 末端ノードのヒストグラムに教師信号を投票する関数 - 引数 : サンプル、ラベルに対する重み、ルートノードのアドレス

normalizeHistograms - 末端ノードのヒストグラムを正規化する関数 - 引数 : ノードのアドレス

traversal - 再帰により決定木を走査する関数 - 引数 : ルートノードのアドレス、サンプル集合 - 末端ノードのヒストグラムを返す