![Page 1: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/1.jpg)
Robert Figiel Co-Founder & CTO
Deep LearningImage Classification
Deep LearningImage
Classification
Javier AbadíaLead Developer
![Page 2: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/2.jpg)
WHAT DO WE DO AT STYLESAGE?
Web-Crawling of 100M+ e-commerce products daily.
Analysis of text, machine learning, image-recognition
Visualize insights for fashion brands & retailers
Collect Data Analyze Products Visualize Insights
![Page 3: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/3.jpg)
CHALLENGE: CLASSIFY PRODUCTS FROM IMAGES
• Category: Dress
![Page 4: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/4.jpg)
SOLUTION: CONVOLUTIONAL NEURAL NETWORKS (CNN)
Input(Image Data)
BLACK BOX(for now)
ConvolutionalNeural Network
Output(Probability Vector)
• Dress : 94.8%• Skirt: 4.1%• Jacket: 1.2%• Pant: 0.1%• Socks: 0.01%• ...
![Page 5: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/5.jpg)
TRADITIONAL COMPUTING
algorithminput output
![Page 6: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/6.jpg)
MACHINE LEARNING
model training
input
output
algorithm
new input
new output
![Page 7: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/7.jpg)
MACHINE LEARNING - CLASSIFICATION
Features ClassesSupervised Learning
![Page 8: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/8.jpg)
MACHINE LEARNING - CLASSIFICATION
• Supervised Learning– Decision Trees– Bayesian Algorithms– Regression– Clustering– Neural Networks– …
http://machinelearningmastery.com/a-tour-of-machine-learning-algorithms/
![Page 9: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/9.jpg)
LETTER RECOGNITION
28x28 – gray levels
784
![Page 10: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/10.jpg)
LOGISTIC CLASSIFIERWX+b=Y
784 x 35 + =784 35 35
weights inputfeatures
bias scores
35
probabilities
P = softmax(Y)
![Page 11: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/11.jpg)
GRADIENT DESCENT
![Page 12: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/12.jpg)
CODE USING python/scikit-learn""" based on http://scikit-learn.org/stable/auto_examples/linear_model/plot_iris_logistic.html """
import numpy as npfrom sklearn import linear_model, metrics
N = 50000X = np.array([x.flatten() for x in data['train_dataset'][:N]])Y = data['train_labels'][:N]
solver = 'sag'C = 0.001
# trainlogreg = linear_model.LogisticRegression(C=C, solver=solver)logreg.fit(X, Y)
# testVX = np.array([x.flatten() for x in data['test_dataset']])predicted_labels = logreg.predict(VX)print "%.3f" % (metrics.accuracy_score(predicted_labels, data['test_labels']),)
![Page 13: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/13.jpg)
CODE WITH tensorflowimport tensorflow as tf
graph = tf.Graph()with graph.as_default(): # Input data placeholder tf_train_dataset = tf.placeholder(tf.float32, shape=(batch_size, image_size * image_size)) tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))
# Variables. weights = tf.Variable( tf.truncated_normal([image_size * image_size, num_labels])) biases = tf.Variable(tf.zeros([num_labels]))
# Training computation. logits = tf.matmul(tf_train_dataset, weights) + biases loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(logits, tf_train_labels))
# Optimizer. optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
![Page 14: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/14.jpg)
LINEAR METHODS ARE LIMITED TO LINEAR RELATIONSHIPS
PX ✕W1 +b1 Y s(Y)
PX ✕W1 +b1 Y s(Y)✕W2 +b2
activationfunction(RELU)
![Page 15: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/15.jpg)
CODE WITH tensorflowimport tensorflow as tf
graph = tf.Graph()with graph.as_default(): # Input data placeholder tf_train_dataset = tf.placeholder(tf.float32, shape=(batch_size, image_size * image_size)) tf_train_labels = tf.placeholder(tf.float32, shape=(batch_size, num_labels))
# Variables weights1 = tf.Variable(tf.truncated_normal([image_size * image_size, n_hidden_moves])) biases1 = tf.Variable(tf.zeros([n_hidden_moves]))
weights2 = tf.Variable(tf.truncated_normal([n_hidden_moves, num_labels])) biases2 = tf.Variable(tf.zeros([num_labels]))
# Training model logits1 = tf.matmul(tf_train_dataset, weights1) + biases1 relu_output = tf.nn.relu(logits1) logits2 = tf.matmul(relu_output, weights2) + biases2 loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(logits2, tf_train_labels))
# Optimizer optimizer = tf.train.GradientDescentOptimizer(0.5).minimize(loss)
![Page 16: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/16.jpg)
NN VS CNNNeural Network
(ANY numeric input)Convolutional Neural
Network(IMAGE input)
![Page 17: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/17.jpg)
DEEPLEARNINGMANY LAYERS FOR HIGHER ACCURACY
Example: GoogLeNet architecture (2014), 22 layers
Example: AlexNet (2012)8 layers
![Page 18: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/18.jpg)
ME ABURRO
![Page 19: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/19.jpg)
CHOOSING A MODEL – OPEN SOURCE OPTIONS
• AlexNet (2012)• 8 layers, 16.4% error rate on ImageNet
• GoogLeNet (2014)• 22 layers, 6.66% error rate on ImageNet
• Google Inception v3 (2015)• 48 layers, 3.46% error rate
• Microsoft ResNet (2015)• 152 layers, 3.57% error rate
Yearly competition on ImageNet dataset with 1M images across 1000 object classes – models available open source
Many models open source.No need to re-invent the wheel.
![Page 20: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/20.jpg)
FRAMEWORK – OPEN SOURCE OPTIONS
• Caffe• Developed by UC Berkley, Very efficient algorithms• Implemented GoogLeNet, ResNet• Large community
• Tensorflow• Released 2015 by Google• Ready-to-use Implementions of GoogLeNet, Inception v3• Tensorboard for visualizing training progress
• Torch, Theano, Keras, ...
Many Python frameworks available, all with many examples, good documentation and pre-implemented models
Chose a Python Frame-work that fits your needs
![Page 21: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/21.jpg)
IMPLEMENTING A CNNMODEL – TRAIN - PREDICT
Select / DevelopMODEL
TRAIN/TEST modelwith known images PREDICT
on new Images
Feedback loop Additional Training Data
![Page 22: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/22.jpg)
INFRASTRUCTURE – GPUSUnderlying CNN computations are mainly matrix multiplications GPUs (Graphical Processing Unit) 30-50X faster than CPUs
1 CPU: 2 sec1 GPU: 50ms30-50X faster
vs.
Use GPU based servers for faster training and predictions
![Page 23: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/23.jpg)
![Page 25: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/25.jpg)
![Page 26: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/26.jpg)
![Page 28: Deep learning image classification aplicado al mundo de la moda](https://reader036.vdocuments.net/reader036/viewer/2022070603/587185981a28ab2c198b4d33/html5/thumbnails/28.jpg)
GRACIAS!