Things used in this project

Hardware components:
Pack pro mobile lgnchugrkz
Walabot
×1
Chip%20v1
C.H.I.P.
×1

Code

An image Classification example Python
Such an easy script can be used to classify images gathered by walabot.
import os
import numpy as np
from keras.models import Sequential
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.preprocessing.image import ImageDataGenerator
from keras.layers import Convolution2D, MaxPooling2D, ZeroPadding2D
from keras import optimizers

img_width, img_height = 150, 150

train_data_dir = 'data/train_small'
validation_data_dir = 'data/validation_small'


# loading the images in two groups: training and validation
datagen = ImageDataGenerator(
    rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True)

train_generator = datagen.flow_from_directory(
    train_data_dir,
    target_size=(img_width, img_height),
    batch_size=32,
    class_mode='binary'
)

validation_generator = datagen.flow_from_directory(
    validation_data_dir,
    target_size=(img_width, img_height),
    batch_size=32,
    class_mode='binary'
)

# building the brain
model = Sequential()
model.add(Convolution2D(32, (3, 3), input_shape=(img_width, img_height, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Convolution2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Convolution2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))

model.compile(loss='binary_crossentropy',
             optimizer='rmsprop',
             metrics=['accuracy'])

# training the model
nb_epoch = 30
nb_train_samples = 2048
nb_validation_samples = 832

model.fit_generator(
    train_generator,
    steps_per_epoch=nb_train_samples/32,
    epochs=nb_epoch,
    validation_steps=nb_validation_samples/32)

# validate the weights
model.evaluate_generator(validation_generator, nb_validation_samples)

Credits

69655715399db5fa781b35bde1984fdb
Enrico Colautti
1 project • 3 followers
Software developer, DIYer, scuba diver
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog