SlideShare a Scribd company logo
Deep Learning
Python: Segmentation and classification
About me!
● My name is “Fabio Leandro”, nickname: “fabiosammy”;
● I’m from a tiny city called “Paulo Frontin”;
● Using Linux and “spreading the word” since 2002;
● Web Developer with Ruby on Rails;
● CTO at “Ponto Gestor” company;
● Master degree student at “UTFPR” in “Medianeira”;
● Professor in graduate and postgraduate at “Guairacá” in
“Guarapuava”;
● All the cities are from Paraná state;
My master degree research
Batch of images
classified by the
soil analysis
CNN Network
What’s deep
learning?
Statistics
Linear relationship
Linear regression
Machine learning
Deep learning
Cases of use deep
learning
Computer vision
Speech and Natural Language Processing
Recommender Systems
and more ...
Example
applications
Objects - http://demo.caffe.berkeleyvision.org/
Colorization - http://hi.cs.waseda.ac.jp:8082/
Localization
Pixel level classification and segmentation
Sequence learning
Transfer learning
For transfer learning - Model zoo
In the caffe root you can download the caffe community
models running:
$ ./scripts/download_model_from_gist.sh <gist_id> <dirname>
Or the official caffe models with:
$ ./scripts/download_model_binary.py <dirname>
Recognition
Contests
Mnist - Handwrite Digit recognition
ILSVRC - Imagenet Contest
ILSVRC - Imagenet Contest
Diabetic Retinopathy Contest
● Affects more than 347 million
people worldwide;
● Changes to blood vessels in the
retina lead to aneurysms and
fluid leaks;
● If no treated early, can causes
blindness;
● Provides 17000 images with
classification: 0(healthy) to
4(diseased);
● Winner is Benjamin Graham using
“SparseConvNet” with “Random
Forest” technique;
Deep learning
Deep learning
Deep learning networks
● Randomly Initialized;
● Bayesian;
● Hidden Trajectory;
● Monophone;
● Triphone;
● Convolutional (Most used - Better results in most of
cases);
● Ensemble;
● Biderectional;
● ... ;
CNN models- Most created for imagenet contest
● Lenet - 5 layers;
● Alexnet - 8 Layers;
● ZFNet - 8 Layers;
● VGGNet - 19 layers;
● GoogleNet/Inception - 22 layers;
● ResNet - 152 Layers;
... And you can make/modify for your own problem;
Layers - more importants
● Convolution: 2D;
● Activation: ReLU, tanh and sigmoid;
● Pooling: Max and AVG;
● ElementWise: Sum, product or max of two layers;
● Blobs: The result of layer(if has a value to return);
Flow
DL Benchmark
CPU X GPU
Mnist dataset
● Iterations: 10,000
● Display iterations: 100
● Snapshot: 5,000
● Images: 10,000
● Crop size: 28x28
$ docker run -ti bvlc/caffe:cpu bash
$ cd /opt/caffe
$ ./data/mnist/get_mnist.sh
$ ./examples/mnist/create_mnist.sh
$ ./examples/mnist/train_lenet.sh
## The same for “GPU version”
CPU X GPU - Mnist Dataset - Same notebook
CPU: Intel Core i7 6500U@2.5Ghz:
● At 5,000 iteration:
● 11.8231 iterations/s;
● 8.458s/100 iterations;
● Accuracy = 0.9895;
● Time = 422.90s (~7min);
● At 10,000 iteration:
● 11.2943 iterations/s;
● 8.854s/100 iterations;
● Accuracy = ~0.9901;
● Time = 885.40 (~15min);
GPU: NVIDIA Geforce 930M 4GB:
●
CPU X GPU - Mnist Dataset - Same notebook
CPU: Intel Core i7 6500U@2.5Ghz:
● At 5,000 iteration:
● 11.8231 iterations/s;
● 8.458s/100 iterations;
● Accuracy = 0.9895;
● Time = 422.90s (~7min);
● At 10,000 iteration:
● 11.2943 iterations/s;
● 8.854s/100 iterations;
● Accuracy = ~0.9901;
● Time = 885.40 (~15min);
GPU: NVIDIA Geforce 930M 4GB:
● At 5,000 iteration:
● 51.8834 iterations/s;
● 1.9274s/100 iterations;
● Accuracy = 0.9901;
● Time = 96.37s (~1.5min);
● At 10,000 iteration:
● 58.7952 iterations/s;
● 1.70082s/100 iterations;
● Accuracy = ~0.9903
● Time = 170,08s (~>3min);
The gpu is 5x faster!
And the gtx1060
need only 10s to
do this.
The software is important too!
DL Frameworks
Caffe!
Caffe
● Deep Learning from Berkeley (BVLC);
● Implemented in C++;
● CPU and GPU modes (w/CUDA);
● Python wrapper;
● Command line tools for training and prediction;
● Uses google protobuf based model specification;
● Several data formats (file system, leveldb, lmdb, hdf5);
Interfaces
Pycaffe API
● caffe.Net - Central interface for loading, configuring
and running models;
● caffe.Classifier and caffe.Detector - provide interfaces
for common tasks;
● caffe.SGDSolver - exposes the solving interface;
● caffe.io - handle input / output with processing and
protocol buffers;
● caffe.draw - visualizes network architectures;
● Caffe blobs are exposed as numpy ndarrays for
“easy-of-use”;
It’s show time!
Using examples to
classify
Pycaffe - example of use - Download model
# in $CAFFE_ROOT Downloading model and labels of imagenet
$ ./scripts/download_model_binary.py ../models/bvlc_reference_caffenet
$ ./data/ilsvrc12/get_ilsvrc_aux.sh
# Dependencies on python:
>>> import numpy as np
>>> import caffe
>>> model_def = caffe_root +
'models/bvlc_reference_caffenet/deploy.prototxt'
>>> model_weights = caffe_root +
'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'
>>> net = caffe.Net(model_def, model_weights, caffe.TEST)
Alternate between CPU or GPU mode
>>> caffe.set_mode_cpu()
# OR
>>> caffe.set_device(0)
>>> caffe.set_mode_gpu()
Pycaffe - Example of use - Building transformer
>>> mu = np.load(caffe_root +
'python/caffe/imagenet/ilsvrc_2012_mean.npy')
>>> mu = mu.mean(1).mean(1)
>>> transformer = caffe.io.Transformer({'data':
net.blobs['data'].data.shape})
>>> transformer.set_transpose('data', (2,0,1))
>>> transformer.set_mean('data', mu)
>>> transformer.set_raw_scale('data', 255)
>>> transformer.set_channel_swap('data', (2,1,0))
Transpose an image
Original Red pixel = [255, 0, 0] (shape = 1,1,3)
Transposed Red pixel = [[255], [0], [0]] (shape = 3, 1, 1)
BGR transposed = [[0], [0], [255]] (shape = 3, 1, 1)
Pycaffe - Example of use - Preparing data
>>> image = caffe.io.load_image(caffe_root + 'examples/images/cat.jpg')
>>> transformed_image = transformer.preprocess('data', image)
>>> net.blobs['data'].reshape(1, 3, 227, 227)
>>> net.blobs['data'].data[...] = transformed_image
>>> output = net.forward()
>>> output_prob = output['prob'][0]
Pycaffe - Example of use - Discovering the class
>>> print 'predicted class is:', output_prob.argmax()
predicted class is: 281
>>> labels_file = caffe_root + 'data/ilsvrc12/synset_words.txt'
>>> labels = np.loadtxt(labels_file, str, delimiter='t')
>>> print 'output label:', labels[output_prob.argmax()]
output label: n02123045 tabby, tabby cat
Pycaffe - Example of use - Top N Class
>>> top_inds = output_prob.argsort()[::-1][:5]
>>> print 'probabilities and labels:'
>>> zip(output_prob[top_inds], labels[top_inds])
probabilities and labels:
[(0.31243637, 'n02123045 tabby, tabby cat'),
(0.2379719, 'n02123159 tiger cat'),
(0.12387239, 'n02124075 Egyptian cat'),
(0.10075711, 'n02119022 red fox, Vulpes vulpes'),
(0.070957087, 'n02127052 lynx, catamount')]
Or you can compare images using Distance
# Load images
>>> image_1 = caffe.io.load_image(my_image_1_path)
>>> image_2 = caffe.io.load_image(my_image_2_path)
# Tranform images
>>> transformed_image_1 = transformer.preprocess('data', image_1)
>>> transformed_image_2 = transformer.preprocess('data', image_2)
# Reshape net and load
>>> net.blobs['data'].reshape(2, 3, 227, 227)
>>> net.blobs['data'].data[0, ...] = transformed_image_1
>>> net.blobs['data'].data[1, ...] = transformed_image_2
Or you can compare images using Distance
>>> output = net.forward()
>>> image_1_features = net.blobs[‘fc7’].data[0]
>>> image_2_features = net.blobs[‘fc7’].data[1]
>>> import distance from scipy.spatial
>>> image_1_2_dist = distance.euclidean(image_1_features,
image_2_features)
# if image_1_2 closest to 0, more similars they are
Images
segmentations
Segment you image
Using the opencv
>>> import cv2
>>> image = cv2.imread(image_path)
>>> import segmentation from cv2.ximgproc
>>> selective_search =
segmentation.createSelectiveSearchSegmentation()
>>> selective_search.setBaseImage(image)
>>> segments = selective_search.process()
>>> x, y, w, h = segments[0]
>>> cropped_image = image[y:(y+h), x:(x+w)]
Segmentation algorithms
● Sliding window;
● Selective search;
● Superpixels;
● Bing;
● Edge boxes;
And more...
DL networks for object location
● Region based convolutional network;
● Fast region based convolutional network;
● Single shot multibox detector;
● Region-based fully convolutional networks;
OR you can use a
GUI
NVIDIA DIGITS
NVIDIA DIGITS
Cloud solutions
Where i can learn more?
https://nvidia.qwiklab.com
https://developer.nvidia.com/deep-learning-software
http://caffe.berkeleyvision.org/
http://demo.caffe.berkeleyvision.org/
http://hi.cs.waseda.ac.jp:8082/
https://developer.nvidia.com/digits
http://imatge-upc.github.io/telecombcn-2016-dlcv/
Thank you!
Any questions?
fabiosammy@gmail.com

More Related Content

What's hot

[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
NAVER D2
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
charsbar
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
Tim Bunce
 
Pl python python w postgre-sql
Pl python   python w postgre-sqlPl python   python w postgre-sql
Pl python python w postgre-sql
Piotr Pałkiewicz
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
Laurent Dami
 
Shellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and ConceptShellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and Concept
Julia Yu-Chin Cheng
 
Programming with Python - Adv.
Programming with Python - Adv.Programming with Python - Adv.
Programming with Python - Adv.
Mosky Liu
 
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PROIDEA
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
Nikita Popov
 
Hack Programming Language
Hack Programming LanguageHack Programming Language
Hack Programming Language
Radu Murzea
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
julien pauli
 
Hack and HHVM
Hack and HHVMHack and HHVM
Hack and HHVM
Ewere Diagboya
 

What's hot (13)

[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
 
What you need to remember when you upload to CPAN
What you need to remember when you upload to CPANWhat you need to remember when you upload to CPAN
What you need to remember when you upload to CPAN
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012PL/Perl - New Features in PostgreSQL 9.0 201012
PL/Perl - New Features in PostgreSQL 9.0 201012
 
Pl python python w postgre-sql
Pl python   python w postgre-sqlPl python   python w postgre-sql
Pl python python w postgre-sql
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
Shellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and ConceptShellcode Analysis - Basic and Concept
Shellcode Analysis - Basic and Concept
 
Programming with Python - Adv.
Programming with Python - Adv.Programming with Python - Adv.
Programming with Python - Adv.
 
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
PLNOG20 - Paweł Małachowski - Stress your DUT–wykorzystanie narzędzi open sou...
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Hack Programming Language
Hack Programming LanguageHack Programming Language
Hack Programming Language
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Hack and HHVM
Hack and HHVMHack and HHVM
Hack and HHVM
 

Similar to Deep learning - the conf br 2018

Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Universitat Politècnica de Catalunya
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
InfluxData
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Valeriy Kravchuk
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
Vipin Varghese
 
Apache Submarine: Unified Machine Learning Platform
Apache Submarine: Unified Machine Learning PlatformApache Submarine: Unified Machine Learning Platform
Apache Submarine: Unified Machine Learning Platform
Wangda Tan
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
oscon2007
 
carrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-APIcarrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-API
Yoni Davidson
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
Steve Caron
 
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
Chris Fregly
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Community
 
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
TensorFlow meetup: Keras - Pytorch - TensorFlow.jsTensorFlow meetup: Keras - Pytorch - TensorFlow.js
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
Scaling TensorFlow with Hops, Global AI Conference Santa Clara
Scaling TensorFlow with Hops, Global AI Conference Santa ClaraScaling TensorFlow with Hops, Global AI Conference Santa Clara
Scaling TensorFlow with Hops, Global AI Conference Santa Clara
Jim Dowling
 
Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web site
Sriram Natarajan
 
H2O Design and Infrastructure with Matt Dowle
H2O Design and Infrastructure with Matt DowleH2O Design and Infrastructure with Matt Dowle
H2O Design and Infrastructure with Matt Dowle
Sri Ambati
 
Java in flames
Java in flamesJava in flames
Java in flames
Isuru Perera
 
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL DevroomFlame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Valeriy Kravchuk
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
Chris Fregly
 
Python and Machine Learning
Python and Machine LearningPython and Machine Learning
Python and Machine Learning
trygub
 
Build Large-Scale Data Analytics and AI Pipeline Using RayDP
Build Large-Scale Data Analytics and AI Pipeline Using RayDPBuild Large-Scale Data Analytics and AI Pipeline Using RayDP
Build Large-Scale Data Analytics and AI Pipeline Using RayDP
Databricks
 

Similar to Deep learning - the conf br 2018 (20)

Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
 
Performance Profiling in Rust
Performance Profiling in RustPerformance Profiling in Rust
Performance Profiling in Rust
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
 
Apache Submarine: Unified Machine Learning Platform
Apache Submarine: Unified Machine Learning PlatformApache Submarine: Unified Machine Learning Platform
Apache Submarine: Unified Machine Learning Platform
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
carrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-APIcarrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-API
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
Building Google's ML Engine from Scratch on AWS with GPUs, Kubernetes, Istio,...
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
TensorFlow meetup: Keras - Pytorch - TensorFlow.jsTensorFlow meetup: Keras - Pytorch - TensorFlow.js
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
 
Scaling TensorFlow with Hops, Global AI Conference Santa Clara
Scaling TensorFlow with Hops, Global AI Conference Santa ClaraScaling TensorFlow with Hops, Global AI Conference Santa Clara
Scaling TensorFlow with Hops, Global AI Conference Santa Clara
 
Dynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web siteDynamic Tracing of your AMP web site
Dynamic Tracing of your AMP web site
 
H2O Design and Infrastructure with Matt Dowle
H2O Design and Infrastructure with Matt DowleH2O Design and Infrastructure with Matt Dowle
H2O Design and Infrastructure with Matt Dowle
 
Java in flames
Java in flamesJava in flames
Java in flames
 
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL DevroomFlame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
Flame Graphs for MySQL DBAs - FOSDEM 2022 MySQL Devroom
 
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
High Performance TensorFlow in Production - Big Data Spain - Madrid - Nov 15 ...
 
Python and Machine Learning
Python and Machine LearningPython and Machine Learning
Python and Machine Learning
 
Build Large-Scale Data Analytics and AI Pipeline Using RayDP
Build Large-Scale Data Analytics and AI Pipeline Using RayDPBuild Large-Scale Data Analytics and AI Pipeline Using RayDP
Build Large-Scale Data Analytics and AI Pipeline Using RayDP
 

Recently uploaded

Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
Raheem Muhammad
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
gpww3sf4
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
Robin Haunschild
 
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussionArtificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
OECD Directorate for Financial and Enterprise Affairs
 
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdfWhy Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Ben Linders
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
SkillCertProExams
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
OECD Directorate for Financial and Enterprise Affairs
 
Disaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other usesDisaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other uses
RIDHIMAGARG21
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
Ben Linders
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
Claudio Gallicchio
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
kainatfatyma9
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
kekzed
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
OECD Directorate for Financial and Enterprise Affairs
 
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussionArtificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
artemacademy2
 

Recently uploaded (20)

Proposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP IncProposal: The Ark Project and The BEEP Inc
Proposal: The Ark Project and The BEEP Inc
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
 
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdfBRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
BRIC_2024_2024-06-06-11:30-haunschild_archival_version.pdf
 
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussionArtificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – OECD – June 2024 OECD discussion
 
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
The Intersection between Competition and Data Privacy – COLANGELO – June 2024...
 
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdfWhy Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
Why Psychological Safety Matters for Software Teams - ACE 2024 - Ben Linders.pdf
 
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
ServiceNow CIS-ITSM Exam Dumps & Questions [2024]
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
 
Disaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other usesDisaster Management project for holidays homework and other uses
Disaster Management project for holidays homework and other uses
 
Gamify it until you make it Improving Agile Development and Operations with ...
Gamify it until you make it  Improving Agile Development and Operations with ...Gamify it until you make it  Improving Agile Development and Operations with ...
Gamify it until you make it Improving Agile Development and Operations with ...
 
IEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdfIEEE CIS Webinar Sustainable futures.pdf
IEEE CIS Webinar Sustainable futures.pdf
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
 
Using-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptxUsing-Presentation-Software-to-the-Fullf.pptx
Using-Presentation-Software-to-the-Fullf.pptx
 
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
The Intersection between Competition and Data Privacy – KEMP – June 2024 OECD...
 
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
怎么办理(lincoln学位证书)英国林肯大学毕业证文凭学位证书原版一模一样
 
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
The Intersection between Competition and Data Privacy – CAPEL – June 2024 OEC...
 
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
The Intersection between Competition and Data Privacy – OECD – June 2024 OECD...
 
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
 
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussionArtificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
Artificial Intelligence, Data and Competition – LIM – June 2024 OECD discussion
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
 

Deep learning - the conf br 2018

  • 2. About me! ● My name is “Fabio Leandro”, nickname: “fabiosammy”; ● I’m from a tiny city called “Paulo Frontin”; ● Using Linux and “spreading the word” since 2002; ● Web Developer with Ruby on Rails; ● CTO at “Ponto Gestor” company; ● Master degree student at “UTFPR” in “Medianeira”; ● Professor in graduate and postgraduate at “Guairacá” in “Guarapuava”; ● All the cities are from Paraná state;
  • 3. My master degree research Batch of images classified by the soil analysis CNN Network
  • 10. Cases of use deep learning
  • 12. Speech and Natural Language Processing
  • 19. Pixel level classification and segmentation
  • 22. For transfer learning - Model zoo In the caffe root you can download the caffe community models running: $ ./scripts/download_model_from_gist.sh <gist_id> <dirname> Or the official caffe models with: $ ./scripts/download_model_binary.py <dirname>
  • 24. Mnist - Handwrite Digit recognition
  • 25. ILSVRC - Imagenet Contest
  • 26. ILSVRC - Imagenet Contest
  • 27. Diabetic Retinopathy Contest ● Affects more than 347 million people worldwide; ● Changes to blood vessels in the retina lead to aneurysms and fluid leaks; ● If no treated early, can causes blindness; ● Provides 17000 images with classification: 0(healthy) to 4(diseased); ● Winner is Benjamin Graham using “SparseConvNet” with “Random Forest” technique;
  • 30. Deep learning networks ● Randomly Initialized; ● Bayesian; ● Hidden Trajectory; ● Monophone; ● Triphone; ● Convolutional (Most used - Better results in most of cases); ● Ensemble; ● Biderectional; ● ... ;
  • 31. CNN models- Most created for imagenet contest ● Lenet - 5 layers; ● Alexnet - 8 Layers; ● ZFNet - 8 Layers; ● VGGNet - 19 layers; ● GoogleNet/Inception - 22 layers; ● ResNet - 152 Layers; ... And you can make/modify for your own problem;
  • 32. Layers - more importants ● Convolution: 2D; ● Activation: ReLU, tanh and sigmoid; ● Pooling: Max and AVG; ● ElementWise: Sum, product or max of two layers; ● Blobs: The result of layer(if has a value to return);
  • 33. Flow
  • 35. Mnist dataset ● Iterations: 10,000 ● Display iterations: 100 ● Snapshot: 5,000 ● Images: 10,000 ● Crop size: 28x28 $ docker run -ti bvlc/caffe:cpu bash $ cd /opt/caffe $ ./data/mnist/get_mnist.sh $ ./examples/mnist/create_mnist.sh $ ./examples/mnist/train_lenet.sh ## The same for “GPU version”
  • 36. CPU X GPU - Mnist Dataset - Same notebook CPU: Intel Core i7 6500U@2.5Ghz: ● At 5,000 iteration: ● 11.8231 iterations/s; ● 8.458s/100 iterations; ● Accuracy = 0.9895; ● Time = 422.90s (~7min); ● At 10,000 iteration: ● 11.2943 iterations/s; ● 8.854s/100 iterations; ● Accuracy = ~0.9901; ● Time = 885.40 (~15min); GPU: NVIDIA Geforce 930M 4GB: ●
  • 37. CPU X GPU - Mnist Dataset - Same notebook CPU: Intel Core i7 6500U@2.5Ghz: ● At 5,000 iteration: ● 11.8231 iterations/s; ● 8.458s/100 iterations; ● Accuracy = 0.9895; ● Time = 422.90s (~7min); ● At 10,000 iteration: ● 11.2943 iterations/s; ● 8.854s/100 iterations; ● Accuracy = ~0.9901; ● Time = 885.40 (~15min); GPU: NVIDIA Geforce 930M 4GB: ● At 5,000 iteration: ● 51.8834 iterations/s; ● 1.9274s/100 iterations; ● Accuracy = 0.9901; ● Time = 96.37s (~1.5min); ● At 10,000 iteration: ● 58.7952 iterations/s; ● 1.70082s/100 iterations; ● Accuracy = ~0.9903 ● Time = 170,08s (~>3min);
  • 38. The gpu is 5x faster! And the gtx1060 need only 10s to do this.
  • 39. The software is important too!
  • 42. Caffe ● Deep Learning from Berkeley (BVLC); ● Implemented in C++; ● CPU and GPU modes (w/CUDA); ● Python wrapper; ● Command line tools for training and prediction; ● Uses google protobuf based model specification; ● Several data formats (file system, leveldb, lmdb, hdf5);
  • 44. Pycaffe API ● caffe.Net - Central interface for loading, configuring and running models; ● caffe.Classifier and caffe.Detector - provide interfaces for common tasks; ● caffe.SGDSolver - exposes the solving interface; ● caffe.io - handle input / output with processing and protocol buffers; ● caffe.draw - visualizes network architectures; ● Caffe blobs are exposed as numpy ndarrays for “easy-of-use”;
  • 45. It’s show time! Using examples to classify
  • 46. Pycaffe - example of use - Download model # in $CAFFE_ROOT Downloading model and labels of imagenet $ ./scripts/download_model_binary.py ../models/bvlc_reference_caffenet $ ./data/ilsvrc12/get_ilsvrc_aux.sh # Dependencies on python: >>> import numpy as np >>> import caffe >>> model_def = caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt' >>> model_weights = caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel' >>> net = caffe.Net(model_def, model_weights, caffe.TEST)
  • 47. Alternate between CPU or GPU mode >>> caffe.set_mode_cpu() # OR >>> caffe.set_device(0) >>> caffe.set_mode_gpu()
  • 48. Pycaffe - Example of use - Building transformer >>> mu = np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy') >>> mu = mu.mean(1).mean(1) >>> transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape}) >>> transformer.set_transpose('data', (2,0,1)) >>> transformer.set_mean('data', mu) >>> transformer.set_raw_scale('data', 255) >>> transformer.set_channel_swap('data', (2,1,0))
  • 49. Transpose an image Original Red pixel = [255, 0, 0] (shape = 1,1,3) Transposed Red pixel = [[255], [0], [0]] (shape = 3, 1, 1) BGR transposed = [[0], [0], [255]] (shape = 3, 1, 1)
  • 50. Pycaffe - Example of use - Preparing data >>> image = caffe.io.load_image(caffe_root + 'examples/images/cat.jpg') >>> transformed_image = transformer.preprocess('data', image) >>> net.blobs['data'].reshape(1, 3, 227, 227) >>> net.blobs['data'].data[...] = transformed_image >>> output = net.forward() >>> output_prob = output['prob'][0]
  • 51. Pycaffe - Example of use - Discovering the class >>> print 'predicted class is:', output_prob.argmax() predicted class is: 281 >>> labels_file = caffe_root + 'data/ilsvrc12/synset_words.txt' >>> labels = np.loadtxt(labels_file, str, delimiter='t') >>> print 'output label:', labels[output_prob.argmax()] output label: n02123045 tabby, tabby cat
  • 52. Pycaffe - Example of use - Top N Class >>> top_inds = output_prob.argsort()[::-1][:5] >>> print 'probabilities and labels:' >>> zip(output_prob[top_inds], labels[top_inds]) probabilities and labels: [(0.31243637, 'n02123045 tabby, tabby cat'), (0.2379719, 'n02123159 tiger cat'), (0.12387239, 'n02124075 Egyptian cat'), (0.10075711, 'n02119022 red fox, Vulpes vulpes'), (0.070957087, 'n02127052 lynx, catamount')]
  • 53. Or you can compare images using Distance # Load images >>> image_1 = caffe.io.load_image(my_image_1_path) >>> image_2 = caffe.io.load_image(my_image_2_path) # Tranform images >>> transformed_image_1 = transformer.preprocess('data', image_1) >>> transformed_image_2 = transformer.preprocess('data', image_2) # Reshape net and load >>> net.blobs['data'].reshape(2, 3, 227, 227) >>> net.blobs['data'].data[0, ...] = transformed_image_1 >>> net.blobs['data'].data[1, ...] = transformed_image_2
  • 54. Or you can compare images using Distance >>> output = net.forward() >>> image_1_features = net.blobs[‘fc7’].data[0] >>> image_2_features = net.blobs[‘fc7’].data[1] >>> import distance from scipy.spatial >>> image_1_2_dist = distance.euclidean(image_1_features, image_2_features) # if image_1_2 closest to 0, more similars they are
  • 57. Using the opencv >>> import cv2 >>> image = cv2.imread(image_path) >>> import segmentation from cv2.ximgproc >>> selective_search = segmentation.createSelectiveSearchSegmentation() >>> selective_search.setBaseImage(image) >>> segments = selective_search.process() >>> x, y, w, h = segments[0] >>> cropped_image = image[y:(y+h), x:(x+w)]
  • 58. Segmentation algorithms ● Sliding window; ● Selective search; ● Superpixels; ● Bing; ● Edge boxes; And more...
  • 59. DL networks for object location ● Region based convolutional network; ● Fast region based convolutional network; ● Single shot multibox detector; ● Region-based fully convolutional networks;
  • 60. OR you can use a GUI
  • 64. Where i can learn more? https://nvidia.qwiklab.com https://developer.nvidia.com/deep-learning-software http://caffe.berkeleyvision.org/ http://demo.caffe.berkeleyvision.org/ http://hi.cs.waseda.ac.jp:8082/ https://developer.nvidia.com/digits http://imatge-upc.github.io/telecombcn-2016-dlcv/