Classifying images

Image Modeling with Keras

Ariel Rokem

Senior Data Scientist, University of Washington

Image classification

Image Modeling with Keras

Image classification: training

Image Modeling with Keras

Image classification: training

Image Modeling with Keras

Image classification: training

Image Modeling with Keras

Image classification: evaluation

Image Modeling with Keras

Image classification: evaluation

Image Modeling with Keras

Representing class data: one-hot encoding

labels = ["shoe", "dress", "shoe", "t-shirt", 
          "shoe", "t-shirt", "shoe", "dress"]
Image Modeling with Keras

Representing class data: one-hot encoding

array([[0., 0., 1.],    <= shoe
       [0., 1., 0.],    <= dress
       [0., 0., 1.],    <= shoe
       [1., 0., 0.],    <= t-shirt
       [0., 0., 1.],    <= shoe
       [1., 0., 0.],    <= t-shirt
       [0., 0., 1.],    <= shoe
       [0., 1., 0.]])   <= dress
Image Modeling with Keras

One-hot encoding

categories = np.array(["t-shirt", "dress", "shoe"])

n_categories = 3 ohe_labels = np.zeros((len(labels), n_categories))
for ii in range(len(labels)):
jj = np.where(categories == labels[ii])
ohe_labels[ii, jj] = 1
Image Modeling with Keras

One-hot encoding: testing predictions

test
array([[0., 0., 1.], 
       [0., 1., 0.], 
       [0., 0., 1.], 
       [0., 1., 0.], 
       [0., 0., 1.],
       [0., 0., 1.],
       [0., 0., 1.],
       [0., 1., 0.]])
(test * prediction).sum()
6.0

prediction
array([[0., 0., 1.], 
       [0., 1., 0.], 
       [0., 0., 1.], 
       [1., 0., 0.], <= incorrect
       [0., 0., 1.],
       [1., 0., 0.], <= incorrect
       [0., 0., 1.], 
       [0., 1., 0.]])
Image Modeling with Keras

Let's practice!

Image Modeling with Keras

Preparing Video For Download...