BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... ·...

20
BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Transcript of BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... ·...

Page 1: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

BIL 722 : Deep Learning For Computer Vision

Caffe Tutorial

Çağdaş BAK

Page 2: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

What is, Why Caffe ?

• Open source Deep Learning Framework. – Berkeley Vision and Learning Center (BVLC)

• Expression : Models and optimizations are defined as plaintext schemas.

• Speed : for research and industry alike speed is crucial for state of the art models and massive data.

• Modularity : new tasks and settings require flexibity and extension.

• Openness : scientific and applied progress call for common code, reference models and reproducibility.

• Community

from Kai KANG

Page 3: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

How to Get Started?

• Official website – http://caffe.berkeleyvision.org

• GitHub page – https://github.com/BVLC/caffe

• Installation instructions – http://caffe.berkeleyvision.org/installation.html

– http://web.cs.hacettepe.edu.tr/~aykut/classes/spring2016/bil722/

from Kai KANG

Page 4: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Caffe Structures

• Blob : Stores data and derivatives

• Layer : Transforms bottom blobs to top blobs

• Net : Many layers, computes gradients via fw/bw

• Solver : Uses gradiens to update weights

from Andrej Karpathy

Page 5: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Caffe Protocol Buffers

• Like strongly typed, binary JSON

• Define message types in .proto file

• Define messages in .prototxt or .binaryproto files

– Caffe also uses .caffemodels

– All caffe messages; • https://github.com/BVLC/caffe/blob/85bb397acfd383a676c125c7

5d877642d6b39ff6/src/caffe/proto/caffe.proto

from Andrej Karpathy

Page 6: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

A Caffe Layer

from Yangqing Jia

Page 7: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

A Caffe Network

from Kai KANG

Page 8: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

A Caffe Network (Prototxt)

from Andrej Karpathy

Page 9: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Basic Steps

• Convert data

• Define net

• Define solver

• Train

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 10: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Basic Steps

• Convert data – Lightning Memory-Mapped Database

• https://en.wikipedia.org/wiki/Lightning_Memory_mapped_Database

– Hierarchical Data Format • https://en.wikipedia.org/wiki/Hierarchical_Data_Format

– Text Based • .txt

• Define net

• Define solver

• Train

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 11: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Basic Steps

• Convert data

• Define net

– As prototxt

• Define solver

• Train

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 12: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Basic Steps

• Convert data

• Define net

• Define solver

– As prototxt

• Train

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 13: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Basic Steps

• Convert data

• Define net

• Define solver

• Train & Feature Extract

– With pretrained weights (finetuning)

– Or initial weights

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 14: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Caffe Model Zoo

• https://github.com/BVLC/caffe/wiki/Model-Zoo

• http://caffe.berkeleyvision.org/model_zoo.html

• Keep in Mind !!!

– We need large amount of data.

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 15: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Finetuning

• Initialize your network with using pretrained weights.

• Train your network with your own data.

IF Your data <<<<< necessary amount

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 16: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Wrappers

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 17: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Installation

• Mac OS-X

– http://web.cs.hacettepe.edu.tr/~aykut/classes/spring2016/bil722

• UBUNTU

– http://web.cs.hacettepe.edu.tr/~aykut/classes/spring2016/bil722/

• Windows

– https://github.com/niuzhiheng/caffe

BIL722 : Deep Learning For Computer

Vision / Caffe Tutorial

Page 18: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Hardware Requirements (for GPU Support)

• Nvidia Tesla K40s

• Nvidia Tesla K20s

• Nvidia Titans

• Nvidia GTX 980s

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 19: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

Usefull Links

• http://caffe.berkeleyvision.org/ • https://github.com/BVLC/caffe • https://github.com/BVLC/caffe/wiki/Model-Zoo • http://caffe.berkeleyvision.org/tutorial/ • http://caffe.berkeleyvision.org/installation.html • https://github.com/niuzhiheng/caffe • http://caffe.berkeleyvision.org/doxygen/annotated.html • http://caffe.berkeleyvision.org/development.html • http://caffe.berkeleyvision.org/gathered/examples/feature_extraction.html • http://caffe.berkeleyvision.org/gathered/examples/imagenet.html • http://caffe.berkeleyvision.org/gathered/examples/mnist.html • http://www.nvidia.com.tr/page/home.html • https://developer.nvidia.com/cudnn • https://developer.nvidia.com/deep-learning • https://developer.nvidia.com/deep-learning-courses

BIL722 : Deep Learning For Computer Vision / Caffe Tutorial

Page 20: BIL 722 : Deep Learning For Computer Vision Caffe Tutorialaykut/classes/spring2016/bil722/... · BIL 722 : Deep Learning For Computer Vision Caffe Tutorial Çağdaş BAK

BIL 722 : Deep Learning For Computer Vision

Caffe Tutorial

Çağdaş BAK