Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard...

34
Introduction to Action Recognition in Python @wideio Bertrand NOUVEL, [email protected] Jonathan KELSEY, [email protected] Bernard HERNANDEZ, [email protected] PYDATA LONDON 2014

description

Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

Transcript of Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard...

Page 1: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

Introduction to

Action Recognition

in Python@wideio

Bertrand NOUVEL, [email protected]

Jonathan KELSEY, [email protected]

Bernard HERNANDEZ, [email protected]

PYDATA LONDON 2014

Page 2: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Outline

- (While you download the data) Forewords & Overview

- PART 1: Video-processing in python

- PART 2: The pipeline in details

- PART 3: Putting it together

Page 3: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

FOREWORDS

Page 4: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

GETTING READY

Python 2.x / 3.x

Numy/Scipy

PIL

OpenCV2

ANACONDA

WAKARI

GET THE ABSOLUTELY ESSENTIAL PACKAGES :

1)

2)GET THE SOURCE CODE

git clone https://bitbucket.org/wideio/pydata.git

Page 5: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

WHO WE ARE

WIDE IO - Democratising the best algorithms

startup + consultancy

Page 6: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Why do Computer Vision in Python?

Computer vision is difficult.

Multiparadigm

Best community

Lots of packages

Operator

overloading

Readable

Reflexive

Lightweight

Python is 1000 slower than C++

“””

Page 7: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

ACTION RECOGNITION

Page 8: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

What is action recognition ?

SEMANTIC GAPKTH, Human action dataset (Laptev)

Classify actions

Classification task

Page 9: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Types of Systems

ACTION SPECIFICHOLISTIC

APPROACHES

FEATURE BASED

APPEARANCE

BASED

DEEP LEARNING

Many priors Less priors

Page 10: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

The Very-Traditional Pipeline

RAW DATA FEATURE-EXTRACTION MACHINE LEARNING

Page 11: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

The Very-Traditional Pipeline

VIDEO

FRAMESSPARSIFICATION

CLASSIFICATION

METHOD

Page 12: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

The Very-Traditional Pipeline

VIDEO

FRAMESBAGS OF KEYPOINTS SVM

Page 13: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

PART I

PROCESSING

VIDEOS

TOWARDS FRAMEWORKS

Page 14: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

- PYFFMPEG (outdated)

- OPENCV

- MLT

- ON WAKARI

Reading Videos

anaconda$ vi io/player_mlt.py

Page 15: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

- PYFFMPEG (outdated)

- OPENCV

- MLT

- ON WAKARI

Reading Videos

anaconda$ vi io/player_cv.py

Page 16: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Displaying ImagesRecommended Alternatives

anaconda$ python io/display_pyglet.py

Page 17: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Harris Corner Detector

Detecting interest points:

imsmooth=scipy.ndimage.gaussian_filter

def harris(I,alpha=0.04,si=1):

Ix,Iy = scipy.gradient(I)

H11 = imsmooth(Ix*Ix, si)

H12 = imsmooth(Ix*Iy, si)

H22 = imsmooth(Iy*Iy, si)

return ((H11*H22 - H12**2)

- alpha*(H11+H22)**2)

anaconda$ python keypoints/harris.py

Page 18: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Optical flow - wrapper based code

anaconda$ python keyponats/custom_feature.py

Page 19: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Use the two previous elements to compute keypoints that contain information about the movement

Ideas for extension: Make the same with a pyramidal approach.

Spatio-temporal keypoints

anaconda$ python keyponats/custom_feature.py

Page 20: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

PART II

UNDERSTANDING THE KEY

ELEMENTS OF THE PIPELINE

Page 21: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Feature extractions

Page 22: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

SIFT (128)

SURF (64)Descriptor vector

Feature extractions

Page 23: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Algorithms:

Type (density, connectivity, …)

Dimension (descriptor, position, …)

Recursive clustering

Connectivity (ward) Centroid (k-means) Density (optics)

Page 24: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Page 25: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Page 26: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Page 27: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Support Vector Machines

Page 28: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Support Vector Machines

Weighted-Support Vector Machines

Different support

Page 29: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Support Vector Machines

Weighted-Support Vector Machines

Different support

Different relevance (outliers)

Page 30: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

PART III

PUTTING EVERYTHING

TOGETHER

Page 31: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Feature detection

Clustering

PCA Projection

BOW

Eigen Vectors & Mean

Graphic ModelModel.model

centers

Page 32: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Distance of projection to BOW cluster centers with metric

Mean of stack to create histogram

Normalise (Area=1)

Invert with 'discriminator' to turn into weighting

PCA project with graphic model

Feature detection stack for image

Page 33: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

WIDE IO - DEMOCRATISING THE BEST ALGORITHMS

INTRODUCTION TO ACTION RECOGNITION PYDATA LONDON 2014 - BERNARD HERNANDEZ - JONATHAN KESLEY - BERTRAND NOUVEL

Training data

Feature computer

Feature stack

Param grid

Training Labels

SVM predict all

Testing labelsTesting data

SVM auto train

Page 34: Introduction to Action Recognition in Python by Bertrand Nouvel, Jonathan Kelsey, and Bernard Hernandez

Introduction to

Action Recognition

in Python@wideio

Bertrand NOUVEL, [email protected]

Jonathan KELSEY, [email protected]

Bernard HERNANDEZ, [email protected]

PYDATA LONDON 2014