• No results found

CAP5415 Computer Vision

N/A
N/A
Protected

Academic year: 2021

Share "CAP5415 Computer Vision"

Copied!
67
0
0

Loading.... (view fulltext now)

Full text

(1)

CAP5415

Computer Vision

Yogesh S Rawat [email protected] HEC-241 10/13/2020 CAP5415 - Lecture 11 1

(2)

Administrative details

(3)

Pop quiz bonus

• Will be updated later on Webcourse

• You can check your scores

(4)

Programming assignment 1

• Due 16

th

, Friday

(5)

Course project

• Deadline – 27

th

October

• Send a short description

(6)

Feedback

• Course speed

• Sometimes fast

• Pop quiz

• 30 sec not enough

• Information not on slides

• Live programming demonstrations

• More programming assignments

• No grading

(7)

Questions?

(8)

Classification - I

Lecture 11

(9)

Classification

• Categorizing given set of data into classes

(10)

Classification – computer vision

• Digit classification

• MNIST • Multi-mnist • SVHN

• Object classification

• CIFAR-10 • CIFAR-100 • ImageNET 10/13/2020 CAP5415 - Lecture 11 10

(11)

Object Recognition

• Problem:

Given an image A, does A contain an image of a person?

CAP5415 - Lecture 11 11

(12)

Object Recognition

• Problem:

Given an image A, does A contain an image of a person?

CAP5415 - Lecture 11 12

YES

(13)

Object Recognition

• Problem:

Given an image A, does A contain an image of a person?

CAP5415 - Lecture 11 13

NO

(14)

Image classification - ImageNet

• Images for each category of

WordNet

• 1000 classes

• 1.2M images

• 100K test

• Top 5 error

10/13/2020 CAP5415 - Lecture 11 14

(15)

Dataset split

Training Images Testing Images Validation Images - Secret labels - Measure error - Train classifier - Measure error

- Tune model hyperparameters

Random train/validate splits = cross validation

(16)

Prediction Labels Images Training

Training

Image Features Image Features

Testing

Image not in training set Trained classifier Apply classifier

Slide credit: D. Hoiem and L. Lazebnik

(17)

Features

• Raw pixels

• Histograms

• Templates

• SIFT

• GIST

• HOG

• SURF

• …

L. Lazebnik 10/13/2020 CAP5415 - Lecture 11 17

(18)

Prediction Labels Images Training

Training

Image Features Image Features

Testing

Image not in training set Trained classifier Apply classifier

Slide credit: D. Hoiem and L. Lazebnik

(19)

Prediction Labels Images Training

Training

Image Features Image Features

Testing

Image not in training set Trained classifier Apply classifier

Slide credit: D. Hoiem and L. Lazebnik

(20)

The machine learning framework

• Apply a prediction function to a feature representation of the image to get the desired output:

f( ) = “apple”

f( ) = “tomato”

f( ) = “cow”

Slide credit: L. Lazebnik

(21)

f(x) = y

Training: Given a training set of labeled examples:

{(x1,y1), …, (xN,yN)}

Estimate the prediction function f by minimizing the prediction error on the training set.

Testing: Apply f to an unseen test example xu and output the predicted value yu = f(xu) to classify xu.

Output (label) Prediction function

or classifier

Image feature

Slide credit: L. Lazebnik

The machine learning framework

(22)

Classification

Assign x to one of two (or

more) classes.

A decision rule divides input

space into decision regions

separated by decision

boundaries – literally

boundaries in the space of

the features.

L. Lazebnik

(23)

Classification

Assign x to one of two (or

more) classes.

A decision rule divides input

space into decision regions

separated by decision

boundaries – literally

boundaries in the space of

the features.

L. Lazebnik

(24)

Classifiers: Nearest neighbor

f(x) = label of the training example nearest to x

• All we need is a distance function for our inputs • No training required! Test example Training examples from class 1 Training examples from class 2

Slide credit: L. Lazebnik

(25)

Pop quiz?

(26)

Classifiers: Nearest neighbor

Training examples from class 1 Training examples from class 2

What does the decision boundary look like?

(27)

Classifiers: Nearest neighbor

10/13/2020 CAP5415 - Lecture 11 27

(28)

Classifiers: Nearest neighbor

10/13/2020 CAP5415 - Lecture 11 28

A

B

C

Options A. A B. B C. C D. None of these

(29)

Classifiers: Nearest neighbor

10/13/2020 CAP5415 - Lecture 11 29

A

B

C

Options A. A B. B C. C D. None of these

(30)

Classifiers: Nearest neighbor

10/13/2020 CAP5415 - Lecture 11 30

(31)

Classifiers: Nearest neighbor

Training examples from class 1 Training examples from class 2

What does the decision boundary look like?

(32)

Decision boundary for NN Classifier

Divides input space into decision regions separated by decision

boundaries – Voronoi.

Voronoi partitioning of feature space for two-category

2D and 3D data

from Duda et al. Source: D. Lowe

(33)

K-nearest neighbor

x x x x x x x x o o o o o o o x2 x1 + + x x x x x x x x o o o o o o o x2 x1 + + 1-nearest x x x x x x x x o o o o o o o x2 x1 + + 3-nearest x x x x x x x x o o o o o o o x2 x1 + + 5-nearest 10/13/2020 CAP5415 - Lecture 11 33

(34)

Algorithm

1. Get features for training samples

2. Get features for testing sample

3. For each training sample

1. Computer distance from testing sample

4. Sort distance vector for all samples

5. Pick classes based on top k samples

(35)

K-nearest neighbor

• Pros

• Simple and easy to implement • No training required

• Classification, regression, search, etc.

• Cons

• Slow with large samples

• Slow with high dimensional features

(36)

Classifiers: Linear

Find a linear function to separate the classes

Slide credit: L. Lazebnik Training examples from class 1 Training examples from class 2 10/13/2020 CAP5415 - Lecture 11 36

(37)

Motivation

10/13/2020 CAP5415 - Lecture 11 37

denotes +1 denotes -1

How would you classify this data?

(38)

Motivation

10/13/2020 CAP5415 - Lecture 11 38

denotes +1 denotes -1

How would you classify this data?

(39)

Motivation

10/13/2020 CAP5415 - Lecture 11 39

denotes +1 denotes -1

How would you classify this data?

(40)

Motivation

10/13/2020 CAP5415 - Lecture 11 40

denotes +1 denotes -1

How would you classify this data?

(41)

Motivation

10/13/2020 CAP5415 - Lecture 11 41

denotes +1 denotes -1

Any of these would be fine..

(42)

Classifier Design

10/13/2020 CAP5415 - Lecture 11 42

denotes +1 denotes -1

Define the margin of a linear classifier as the width that the boundary could be increased by before hitting a datapoint.

(43)

Maximum Margin

10/13/2020 CAP5415 - Lecture 11 43 denotes +1 denotes -1 The maximum margin linear classifier is the

linear classifier with the, maximum

margin.

This is the simplest kind of SVM (Called an LSVM)

(44)

Maximum Margin

10/13/2020 CAP5415 - Lecture 11 44 denotes +1 denotes -1 The maximum margin linear classifier is the

linear classifier with the, maximum

margin.

This is the simplest kind of SVM (Called an LSVM)

Support Vectors are those data points that the margin pushes up against

(45)

SVM - background

• A supervised approach for classification and regression

(46)

SVM - background

• A supervised approach for classification and regression

• Developed in the computer science society at 1990s, has grown in popularity since then.

(47)

SVM - background

• A supervised approach for classification and regression

• Developed in the computer science society at 1990s • Has grown in popularity since then

• Shown to perform well in variety of settings

• And often considered as one of the best “out-of-the box” classifiers

Neural networks were a big deal in early 90s Kind of delayed Deep Learning era ☺

(48)

SVM - background

• An approach for classification

• Developed in the computer science society at 1990s, has grown in popularity since then.

• Shown to perform well in variety of settings, and often considered as one of the best “out-of-the box” classifiers.

10/13/2020 CAP5415 - Lecture 11 48

Max-margin

Classifier

Support

Vector

Classifier

Support

Vector

Machines

(49)

Maximal-Margin Classifier

• In a p-dimensional space, a hyperplane is a flat affine subspace of

dimension p-1.

(50)

Maximal-Margin Classifier

• In a p-dimensional space, a hyperplane is a flat affine subspace of

dimension p-1.

• Ex. In 2D, a hyperplane is 1D line, • Ex. In 3D, a hyperplane is 2D plane.

(51)

Maximal-Margin Classifier

• In a p-dimensional space, a hyperplane is a flat affine subspace of

dimension p-1.

• Ex. In 2D, a hyperplane is 1D line, • Ex. In 3D, a hyperplane is 2D plane.

10/13/2020 CAP5415 - Lecture 11 51

(52)

Maximal-Margin Classifier

• In a p-dimensional space, a hyperplane is a flat affine subspace of

dimension p-1.

• Ex. In 2D, a hyperplane is 1D line, • Ex. In 3D, a hyperplane is 2D plane.

10/13/2020 CAP5415 - Lecture 11 52

Hyperplane for 2D data. General hyperplane definition

(53)

Maximal-Margin Classifier

• In a p-dimensional space, a hyperplane is a flat affine subspace of

dimension p-1.

• Ex. In 2D, a hyperplane is 1D line, • Ex. In 3D, a hyperplane is 2D plane.

10/13/2020 CAP5415 - Lecture 11 53

Hyperplane for 2D data. General hyperplane definition

(54)

Max-margin classifier

10/13/2020 CAP5415 - Lecture 11 54

Left: There are two classes of observations: blue and in purple (each of which has

measurements on two variables). Three separating hyperplanes, out of many possible, are

shown in black. Right: A separating hyperplane is shown in black: a test observation that falls in the blue portion of the grid will be assigned to the blue class, and a test observation that falls into the purple portion of the grid will be assigned to the purple class.

(55)

Max-margin classifier

10/13/2020 CAP5415 - Lecture 11 55

There are two classes of observations, shown in blue and in purple. The

maximal margin hyperplane is shown as a solid line.

The margin is the distance from the solid line to either of the dashed lines. The two blue points and the purple point that lie on the dashed lines are the support vectors, and the distance from those points to the margin

is indicated by arrows.

The purple and blue grid indicates the decision rule made by a classifier based on this separating hyperplane.

(56)

Construction of Max-Margin Classifier

• Consider n training observations

(57)

Construction of Max-Margin Classifier

• Consider n training observations

• Associated class labels

(58)

Construction of Max-Margin Classifier

• Consider n training observations

• Associated class labels

• Max-margin hyperplane is the solution to:

(59)

Construction of Max-Margin Classifier

• Consider n training observations

• Associated class labels

• Max-margin hyperplane is the solution to:

• It ensures that each observation is on the correct side

• at least a distance M from the hyperplane

(60)

SV Classifier

10/13/2020 CAP5415 - Lecture 11 60

In practice we are sometimes faced with non-linear class boundaries. Support vector classifier or

any linear classifier will perform poorly here

Left: The observations fall into two classes, with a non-linear boundary between them.

(61)

Φ: x → φ(x)

Nonlinear SVMs

Map the original input space to some

higher-dimensional feature space where the training set is

separable:

Slide credit: Andrew Moore

(62)

10/13/2020 CAP5415 - Lecture 11 62

Disadvantages of Linear Decision Surfaces

Var1

(63)

10/13/2020 CAP5415 - Lecture 11

Advantages of non-linear Decision Surfaces

Var1

Var2

(64)

SVM Classifier

10/13/2020 CAP5415 - Lecture 11 64

Left: An SVM with a polynomial kernel of degree 3 is applied to the non-linear data from previous

slides, resulting in a far more appropriate decision rule.

Right: An SVM with a radial kernel is applied. In this example, either kernel is capable of capturing

(65)

What about multi-class SVMs?

• Unfortunately, there is no “definitive” multi-class SVM. • In practice, we combine multiple two-class SVMs

• One vs. others

• Training: learn an SVM for each class vs. the others

• Testing: apply each SVM to test example and assign to it the class of the SVM that returns the highest decision value

• One vs. one

• Training: learn an SVM for each pair of classes

• Testing: each learned SVM “votes” for a class to assign to the test example

Slide credit: L. Lazebnik

(66)

SVMs: Pros and cons

• Pros

• Many publicly available SVM packages:

http://www.kernel-machines.org/software

• Kernel-based framework is very powerful, flexible

• SVMs work very well in practice, even with very small training sample sizes

• Cons

• No “direct” multi-class SVM, must combine two-class SVMs • Computation, memory

• During training time, must compute matrix of kernel values for every pair of examples

• Learning can take a very long time for large-scale problems

(67)

Questions?

10/13/2020 CAP5415 - Lecture 11 67

Sources for this lecture include materials from works by Abhijit Mahalanobis, James Tompkin, and Ulas Bagci

References

Related documents

The purpose of this dissertation study, which employed a quantitative correlational research design, was to determine if the school-level variables of percentage of African American

Accordingly, the present study has been launched to examine the attitudes, as a main personality factors of a sample of EFL university learners towards English

Frame material: aluminium Number of gears: 21 Extra info: front suspension, Shop price: 395 € (incl.

Projekt je sicer precej obetaven, vendar so avtorji najverjetneje opazili, da so razlike med NoSQL podatkovnimi bazami pogosto prevelike, da bi jih pokrili z enotnim

Instructions for Preparing LREC 2016 Proceedings 1 Introduction Surveying technical documents such as research papers and patents is a critical task for research scientists,

On the other hand, in Spain-North, the site characterized by the largest water input after fl owering and with an average of 132 days from emergence to flowering, current

Henceforth, the purpose of this research is to identify what are the roles of organizational culture (clan, adhocracy, hierarchy, and market) toward employee engagement in a

With pre-treatment scores co-varied, an analysis of covariance of the treated sample (DBT n = 7; TAU n = 11) using the structured interview found a signiŽcantly