Image Classification With Keras

Indy ML

  • No WiFi Password =[
  • Building Image Classifier with Keras
  • Look at the data set subreddit for any data set
  • bart, hommer, lisa, marge

https://github.com/MatthewYancey/IndyML/blob/master/Image%20Classification/code/img_classification.ipynb

Parameters

train = 1800
validation = 100
epochs = 10
batch size =20
classes = 4
width, height = 80, 80
input shape = (width, height, 3 (input channels or colors, rgb))

Data Input

using ImageDataGenerator from keras
train_datagen = imageDataGenerator(
   rescale=1. /255, #scaling image values from 1 to 255
   shear_range = .2 #tweaking
   zoom_range=.2,
   horizontal_flip=True)
  • batch size is the same as the step size
  • what is the reasoning for batch/step size?
  • stay clear of overfitting (high variance)

Train the model

  • add a couple of conv layers, and a couple of layers after that
  • softmax scales everything between 0 and 1, relu caps things at zero, then lets it go as large as it wants
  • compile
  • iterate through pictures in folders

Visualization

  • confusion matrix
  • go back and tweak class weights (weight for miss classification) depending on how the matrix turns out
  • incorporate tensorboard lets us see the accuracy changes
  • pass tensorboard callbacks to fit generator
  • Open Tensorboard (tool) to see accuracy and loss graphs
  • accuracy still climbing, good amount of randomness, would flatten with a longer training period

You'll only receive email when Jacob Weimer publishes a new post

More from Jacob Weimer: