Object Detec)on Ali Farhadi CSE 576 We have talked - - PowerPoint PPT Presentation

object detec on
SMART_READER_LITE
LIVE PREVIEW

Object Detec)on Ali Farhadi CSE 576 We have talked - - PowerPoint PPT Presentation

Object Detec)on Ali Farhadi CSE 576 We have talked about Nearest Neighbor Nave Bayes Logis)c Regression Boos)ng We saw face


slide-1
SLIDE 1

Object ¡Detec)on ¡

Ali ¡Farhadi ¡ CSE ¡576 ¡

slide-2
SLIDE 2

We ¡have ¡talked ¡about ¡

  • Nearest ¡Neighbor ¡ ¡
  • Naïve ¡Bayes ¡
  • Logis)c ¡Regression ¡
  • Boos)ng ¡ ¡
  • We ¡saw ¡face ¡detec)on ¡
slide-3
SLIDE 3

Support ¡Vector ¡Machines ¡

slide-4
SLIDE 4

Linear ¡classifiers ¡– ¡Which ¡line ¡is ¡beMer? ¡

Data ¡ Example ¡i ¡

  • w. ¡= ¡∑j ¡w(j) ¡x(j) ¡
slide-5
SLIDE 5

Pick ¡the ¡one ¡with ¡the ¡largest ¡margin! ¡

w.x ¡= ¡∑j ¡w(j) ¡x(j) ¡

w.x ¡+ ¡b ¡= ¡0 ¡ w.x ¡+ ¡b ¡> ¡0 ¡ ¡ w.x ¡+ ¡b ¡>> ¡0 ¡ ¡ w.x ¡+ ¡b ¡< ¡0 ¡ ¡ w.x ¡+ ¡b ¡<< ¡0 ¡ ¡

γ ¡ γ γ ¡ γ ¡

Margin: ¡measures ¡height ¡

  • f ¡w.x+b ¡plane ¡at ¡each ¡

point, ¡increases ¡with ¡ distance ¡

γj = (w.xj + b)yj

Max ¡Margin: ¡two ¡equivalent ¡ forms ¡ ¡

max

w,b min j

γj

(1) ¡ (2) ¡

maxγ,w,b γ ∀j (w.xj + b)yj > γ

slide-6
SLIDE 6

How ¡many ¡possible ¡solu)ons? ¡

w.x ¡+ ¡b ¡= ¡0 ¡

Any ¡other ¡ways ¡of ¡wri)ng ¡the ¡ same ¡dividing ¡line? ¡

  • w.x ¡+ ¡b ¡= ¡0 ¡
  • 2w.x ¡+ ¡2b ¡= ¡0 ¡
  • 1000w.x ¡+ ¡1000b ¡= ¡0 ¡
  • …. ¡
  • Any ¡constant ¡scaling ¡has ¡the ¡

same ¡intersec)on ¡with ¡z=0 ¡ plane, ¡so ¡same ¡dividing ¡line! ¡

Do ¡we ¡really ¡want ¡to ¡max ¡γ,w,b? ¡

¡

maxγ,w,b γ ∀j (w.xj + b)yj > γ

slide-7
SLIDE 7

Review: ¡Normal ¡to ¡a ¡plane ¡

w.x ¡+ ¡b ¡= ¡0 ¡

Key ¡Terms ¡

  • ­‑-­‑ ¡projec)on ¡of ¡xj ¡onto ¡w ¡
  • ­‑-­‑ ¡unit ¡vector ¡normal ¡to ¡w ¡
slide-8
SLIDE 8

Idea: ¡constrained ¡margin ¡

w.x ¡+ ¡b ¡= ¡+1 ¡ w.x ¡+ ¡b ¡= ¡-­‑1 ¡ w.x ¡+ ¡b ¡= ¡0 ¡

x-­‑ ¡ x+ ¡

Final ¡result: ¡can ¡maximize ¡constrained ¡margin ¡by ¡minimizing ¡||w||2!!! ¡

Generally: ¡

x+ = x− + 2γ w ||w||

γ Assume: ¡x+ ¡on ¡posi)ve ¡line, ¡x-­‑ ¡on ¡

nega)ve ¡

¡

w.x+ + b = 1

w.

  • x− + 2γ w

||w|| ⇥ + b = 1

w.x− + b + 2γ w.w ||w|| = 1

|| || γ w.w ||w|| = 1 γ = ||w|| w.w = 1 √w.w

slide-9
SLIDE 9

Max ¡margin ¡using ¡canonical ¡hyperplanes ¡

The ¡assump)on ¡of ¡canonical ¡hyperplanes ¡ (at ¡+1 ¡and ¡-­‑1) ¡changes ¡the ¡objec)ve ¡and ¡ the ¡constraints! ¡

w.x ¡+ ¡b ¡= ¡+1 ¡ w.x ¡+ ¡b ¡= ¡-­‑1 ¡ w.x ¡+ ¡b ¡= ¡0 ¡

x-­‑ ¡ x+ ¡

γ

slide-10
SLIDE 10

Support ¡vector ¡machines ¡(SVMs) ¡

  • Solve ¡efficiently ¡by ¡quadra)c ¡

programming ¡(QP) ¡

– Well-­‑studied ¡solu)on ¡algorithms ¡ – Not ¡simple ¡gradient ¡ascent, ¡but ¡close ¡

  • Hyperplane ¡defined ¡by ¡support ¡

vectors ¡

– Could ¡use ¡them ¡as ¡a ¡lower-­‑dimension ¡ basis ¡to ¡write ¡down ¡line, ¡although ¡we ¡ haven’t ¡seen ¡how ¡yet ¡ – More ¡on ¡this ¡later ¡

w.x ¡+ ¡b ¡= ¡+1 ¡ w.x ¡+ ¡b ¡= ¡-­‑1 ¡ w.x ¡+ ¡b ¡= ¡0 ¡

margin ¡2γ Support ¡Vectors: ¡

  • data ¡points ¡on ¡the ¡

canonical ¡lines ¡ Non-­‑support ¡Vectors: ¡

  • everything ¡else ¡
  • moving ¡them ¡will ¡not ¡

change ¡w ¡

slide-11
SLIDE 11

What ¡if ¡the ¡data ¡is ¡not ¡linearly ¡separable? ¡

Add ¡More ¡Features!!! ¡ What ¡about ¡overfimng? ¡

φ(x) =              x(1) . . . x(n) x(1)x(2) x(1)x(3) . . . ex(1) . . .             

slide-12
SLIDE 12

What ¡if ¡the ¡data ¡is ¡s)ll ¡not ¡linearly ¡separable? ¡

  • First ¡Idea: ¡Jointly ¡minimize ¡w.w ¡

and ¡number ¡of ¡training ¡mistakes ¡

– How ¡to ¡tradeoff ¡two ¡criteria? ¡ – Pick ¡ ¡C ¡on ¡development ¡/ ¡cross ¡valida)on ¡

  • Tradeoff ¡#(mistakes) ¡and ¡w.w ¡

– 0/1 ¡loss ¡ – Not ¡QP ¡anymore ¡ – Also ¡doesn’t ¡dis)nguish ¡near ¡misses ¡and ¡ really ¡bad ¡mistakes ¡ – NP ¡hard ¡to ¡find ¡op)mal ¡solu)on!!! ¡ + C #(mistakes)

slide-13
SLIDE 13

Slack ¡variables ¡– ¡Hinge ¡loss ¡

For ¡each ¡data ¡point: ¡

  • If ¡margin ¡≥ ¡1, ¡don’t ¡care ¡
  • If ¡margin ¡< ¡1, ¡pay ¡linear ¡penalty ¡

w.x ¡+ ¡b ¡= ¡+1 ¡ w.x ¡+ ¡b ¡= ¡-­‑1 ¡ w.x ¡+ ¡b ¡= ¡0 ¡

ξ ξ ξ ξ

+ C Σj ξj

  • ξj

ξj≥0

Slack ¡Penalty ¡C > 0: ¡

  • C=∞ ¡have ¡to ¡separate ¡the ¡data! ¡
  • C=0 ¡ignore ¡data ¡en)rely! ¡
  • Select ¡on ¡dev. ¡set, ¡etc. ¡

¡

slide-14
SLIDE 14

Side ¡Note: ¡Different ¡Losses ¡

Logis)c ¡regression: ¡

Boos)ng ¡: ¡

All ¡our ¡new ¡losses ¡approximate ¡0/1 ¡loss! ¡ ¡

SVM: ¡

0-­‑1 ¡Loss: ¡

Hinge ¡loss: ¡

ξj = (1 − f(xi)yi)+

slide-15
SLIDE 15

What ¡about ¡mul)ple ¡classes? ¡

slide-16
SLIDE 16

One ¡against ¡All ¡

Learn ¡3 ¡classifiers: ¡

  • + ¡vs ¡{0,-­‑}, ¡weights ¡w+ ¡
  • -­‑ ¡vs ¡{0,+}, ¡weights ¡w-­‑ ¡
  • 0 ¡vs ¡{+,-­‑}, ¡weights ¡w0 ¡

Output ¡for ¡x: ¡ ¡ ¡ ¡y ¡= ¡argmaxi ¡wi.x ¡

w+ ¡ w-­‑ ¡ Any ¡other ¡way? ¡ w0 ¡ Any ¡problems? ¡

slide-17
SLIDE 17

Learn ¡1 ¡classifier: ¡Mul)class ¡SVM ¡

Simultaneously ¡learn ¡3 ¡ sets ¡of ¡weights: ¡

  • How ¡do ¡we ¡

guarantee ¡the ¡ correct ¡labels? ¡

  • Need ¡new ¡

constraints! ¡ For ¡j ¡possible ¡classes: ¡

w+ ¡ w-­‑ ¡ w0 ¡

slide-18
SLIDE 18

Learn ¡1 ¡classifier: ¡Mul)class ¡SVM ¡

Also, ¡can ¡introduce ¡slack ¡variables, ¡as ¡before: ¡

slide-19
SLIDE 19

What ¡if ¡the ¡data ¡is ¡not ¡linearly ¡separable? ¡

Add ¡More ¡Features!!! ¡

φ(x) =              x(1) . . . x(n) x(1)x(2) x(1)x(3) . . . ex(1) . . .             

slide-20
SLIDE 20
slide-21
SLIDE 21

Comparison ¡

Naïve Bayes Logistic Regression Linear SVM Nearest Neighbor Kernelized SVM Learning Objective ( )

( )

∑ ∑

⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ +

i i j j i ij

y P y x P ; log ; | log maximize θ θ

Training

( )

( )

Kr k y r k y x

i i i i ij kj

+ = + = ∧ = =

∑ ∑

δ δ θ 1

Inference

( )

( ) ( ) ( ) ( )

| 1 | log , | 1 1 | 1 log where 1

1 1

= = = = = = = = = = > − + y x P y x P y x P y x P

j j j j j j T T

θ θ x θ x θ

( ) ( ) ( )

( ) ( )

x θ θ x θ θ x

T i i i i

y y P y P − + = +

exp 1 / 1 , | where , | log maximize λ

Gradient ascent

t

T

> x θ

t

T

> x θ

Quadratic programming

  • r subgradient opt.

, 1 such that 2 1 minimize ≥ ∀ − ≥ +

i i T i i i

i y ξ ξ ξ λ x θ θ

Quadratic programming complicated to write most similar features same label Record data

( )

>

i i i i

K y , ˆ x x α

( )

x x , ˆ argmin where

i i i

K i y =

assuming x in {0 1}

slide-22
SLIDE 22

Image ¡Categoriza)on ¡

Training ¡ Labels ¡ Training Images Classifier ¡ Training ¡

Training

Image ¡ Features ¡ Image ¡ Features ¡

Testing

Test Image

Trained ¡ Classifier ¡

Trained ¡ Classifier ¡ Outdoor Prediction

slide-23
SLIDE 23

Example: ¡Dalal-­‑Triggs ¡pedestrian ¡ detector ¡

  • 1. Extract ¡fixed-­‑sized ¡(64x128 ¡pixel) ¡window ¡at ¡

each ¡posi)on ¡and ¡scale ¡

  • 2. Compute ¡HOG ¡(histogram ¡of ¡gradient) ¡

features ¡within ¡each ¡window ¡

  • 3. Score ¡the ¡window ¡with ¡a ¡linear ¡SVM ¡classifier ¡
  • 4. Perform ¡non-­‑maxima ¡suppression ¡to ¡remove ¡
  • verlapping ¡detec)ons ¡with ¡lower ¡scores ¡

Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

slide-24
SLIDE 24

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

slide-25
SLIDE 25
  • Tested ¡with ¡

– RGB ¡ – LAB ¡ – Grayscale ¡

Slightly ¡beMer ¡performance ¡vs. ¡grayscale ¡

slide-26
SLIDE 26

uncentered ¡ centered ¡ cubic-­‑corrected ¡ diagonal ¡ Sobel ¡

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

Outperforms ¡

slide-27
SLIDE 27
  • Histogram ¡of ¡gradient ¡
  • rienta)ons ¡

– Votes ¡weighted ¡by ¡magnitude ¡ – Bilinear ¡interpola)on ¡between ¡ cells ¡

Orienta)on: ¡9 ¡bins ¡(for ¡ unsigned ¡angles) ¡ Histograms ¡in ¡8x8 ¡ pixel ¡cells ¡

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

slide-28
SLIDE 28

Normalize ¡with ¡respect ¡to ¡ surrounding ¡cells ¡

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

slide-29
SLIDE 29

X= ¡

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

# ¡features ¡= ¡15 ¡x ¡7 ¡x ¡9 ¡x ¡4 ¡= ¡3780 ¡ ¡ # ¡cells ¡ # ¡orienta)ons ¡ # ¡normaliza)ons ¡by ¡ neighboring ¡cells ¡

slide-30
SLIDE 30

Training ¡set ¡

slide-31
SLIDE 31

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

pos ¡w ¡ neg ¡w ¡

slide-32
SLIDE 32

pedestrian ¡

Slides ¡by ¡Pete ¡Barnum ¡ Navneet ¡Dalal ¡and ¡Bill ¡Triggs, ¡Histograms ¡of ¡Oriented ¡Gradients ¡for ¡Human ¡Detec)on, ¡CVPR05 ¡

slide-33
SLIDE 33

Detec)on ¡examples ¡

slide-34
SLIDE 34
slide-35
SLIDE 35

Each ¡window ¡is ¡separately ¡classified ¡

slide-36
SLIDE 36