IEEE Spectrum July, 2017 - 18
RESOURCES_hANDS ON
18
|
JUL 2017
|
NORTh AMERICAN
|
makes it much easier to use, especially after looking at Jeremy Howard and Rachel
Thomas's excellent starter course on machine learning.
I started building my neural net system in
earnest. Within several days I had the sorter
working and handling more than a few
classes of parts for the first time.
The next step was to get a training set for
my neural network that was large enough to
make working with over 1,000 types of Lego
pieces possible. At first this seemed like an
insurmountable problem: I could not figure
out how to photograph and label enough
sample parts by hand. Even the most optimistic calculations had me working for six
months or longer flat out.
Then I realized I didn't need to make the
training set all by myself. The machine takes
and labels images. All I need to do is spot
the ones where the computer was wrong
and relabel the image correctly. As the neural net learns, there are fewer mistakes, and
the labeling workload decreases.
The first day I managed to label a starter set
of about 500 assorted scanned pieces. Using those parts to train the net, the next day
the machine sorted 2,000 more parts. About
half of those were wrongly labeled, which I
corrected. The resulting 2,500 parts were
the basis for the next round of training. Another 4,000 parts went through the machine,
90 percent of which were labeled correctly!
So, I had to correct only some 400 parts. By
the end of two weeks I had a training data set
of 20,000 correctly labeled images.
Some classes are still underrepresented in the training set, so I need to increase
the number of images for those. I'll probably
just run through a single sample batch consisting of nothing but those parts. Once the
software is able to reliably classify across
the entire range of parts in my garage, I'll be
pushing through the remainder of those two
tons of bricks. And then I can finally start selling off the results! -JacquEs MatthEIJ
LEGo EX MachIna: A slow conveyer belt
pulls pieces from a hopper [top]. A camera
captures images of individual pieces [second
from top] and a neural net identifies them
[second from bottom]. Air puffs from valves
[bottom] knock sorted pieces into bins.
SPECTRUM.IEEE.ORG
An extended account of the sorter
construction is available on Mattheij's
blog at Jacquesmattheij.com.
↗ Post your coMMEnts at http://spectrum.ieee.org/
lego0717
Jacques mattheiJ (4)
hopper before dropping them onto a much
faster transport belt. This belt moves parts
past a $30 magnifying camera connected
via USB to a PC for identification.
Once identified, the parts have to be moved
from the transport belt to the correct bin. After
some experimenting I settled on putting air
nozzles next to the belt. A well-timed puff
knocks the part into the desired bin.
The biggest challenge of course was identification. First, I had to capture a good image of each piece. There were all kinds of
gotchas here. For instance, parts may be
longer than a single image frame, parts can
be a color that is extremely close to that of the
background, and so on. It was several weeks
before I could reliably stitch and crop scans
automatically, so that I was generating images containing one complete piece of Lego.
Then came the really hard part: identifying
each piece. Lego bricks come in thousands
of distinct shapes and over 100 colors (you
can roughly tell how old someone is by asking them what Lego colors they remember
from their youth). Initially, I tried to classify this
zoo with the OpenCV computer vision library.
Using things like contour matching and circle detection, the system could tell the differences among the basic Lego bricks, but not
much more than that.
Next, I tried Bayesian classification: I chose
distinguishing features and built software
detectors for those. I came up with around
18 features, which included things such as the
height of the part, whether or not it had any
holes, how many studs were visible, and so on.
Building and testing the detectors took
quite a while, but eventually I was able to identify pieces with impressive accuracy. But the
system was too slow to keep up with the machinery. After a few other failed approaches,
and six months in, I decided to try out a neural
network. I settled on using TensorFlow, an immense library produced by the Google Brain
Team. TensorFlow can run on a CPU, but for a
huge speed increase I tapped the parallel computing power of the graphics processing unit in
my US $700 GTX1080 Ti Nvidia video card.
TensorFlow has an arduous learning curve,
but eventually I was pointed to Keras, a
Python language library by François Chollet.
Keras acts as a wrapper for TensorFlow and
http://www.Jacquesmattheij.com
http://spectrum.ieee.org/
http://SPECTRUM.IEEE.ORG
Table of Contents for the Digital Edition of IEEE Spectrum July, 2017
IEEE Spectrum July, 2017 - Cover1
IEEE Spectrum July, 2017 - Cover2
IEEE Spectrum July, 2017 - 1
IEEE Spectrum July, 2017 - 2
IEEE Spectrum July, 2017 - 3
IEEE Spectrum July, 2017 - 4
IEEE Spectrum July, 2017 - 5
IEEE Spectrum July, 2017 - 6
IEEE Spectrum July, 2017 - 7
IEEE Spectrum July, 2017 - 8
IEEE Spectrum July, 2017 - 9
IEEE Spectrum July, 2017 - 10
IEEE Spectrum July, 2017 - 11
IEEE Spectrum July, 2017 - 12
IEEE Spectrum July, 2017 - 13
IEEE Spectrum July, 2017 - 14
IEEE Spectrum July, 2017 - 15
IEEE Spectrum July, 2017 - 16
IEEE Spectrum July, 2017 - 17
IEEE Spectrum July, 2017 - 18
IEEE Spectrum July, 2017 - 19
IEEE Spectrum July, 2017 - 20
IEEE Spectrum July, 2017 - 21
IEEE Spectrum July, 2017 - 22
IEEE Spectrum July, 2017 - 23
IEEE Spectrum July, 2017 - 24
IEEE Spectrum July, 2017 - 25
IEEE Spectrum July, 2017 - 26
IEEE Spectrum July, 2017 - 27
IEEE Spectrum July, 2017 - 28
IEEE Spectrum July, 2017 - 29
IEEE Spectrum July, 2017 - 30
IEEE Spectrum July, 2017 - 31
IEEE Spectrum July, 2017 - 32
IEEE Spectrum July, 2017 - 33
IEEE Spectrum July, 2017 - 34
IEEE Spectrum July, 2017 - 35
IEEE Spectrum July, 2017 - 36
IEEE Spectrum July, 2017 - 37
IEEE Spectrum July, 2017 - 38
IEEE Spectrum July, 2017 - 39
IEEE Spectrum July, 2017 - 40
IEEE Spectrum July, 2017 - 41
IEEE Spectrum July, 2017 - 42
IEEE Spectrum July, 2017 - 43
IEEE Spectrum July, 2017 - 44
IEEE Spectrum July, 2017 - 45
IEEE Spectrum July, 2017 - 46
IEEE Spectrum July, 2017 - 47
IEEE Spectrum July, 2017 - 48
IEEE Spectrum July, 2017 - 49
IEEE Spectrum July, 2017 - 50
IEEE Spectrum July, 2017 - 51
IEEE Spectrum July, 2017 - 52
IEEE Spectrum July, 2017 - Cover3
IEEE Spectrum July, 2017 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1017
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0917
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0817
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0717
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0617
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0517
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0417
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0317
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0217
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0117
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1016
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0916
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0816
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0716
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0616
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0516
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0416
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0316
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0216
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0116
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1015
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0915
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0815
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0715
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0615
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0515
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0415
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0315
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0215
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0115
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1014
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0914
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0814
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0714
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0614
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0514
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0414
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0314
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0214
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0114
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1013
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0913
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0813
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0713
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0613
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0513
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0413
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0313
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0213
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0113
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1012
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0912
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0812
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0712
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0612
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0512
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0412
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0312
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0212
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0112
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1011
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0911
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0811
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0711
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0611
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0511
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0411
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0311
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0211
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0111
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1010
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0910
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0810
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0710
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0610
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0510
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0410
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0310
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0210
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0110
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1009
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0909
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0809
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0709
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0609
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0509
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0409
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0309
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0209
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0109
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1008
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0908
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0808
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0708
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0608
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0508
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0408
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0308
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0208
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0108
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1107
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_1007
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0907
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0807
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0707
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0607
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0507
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0407
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0307
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0207
https://www.nxtbook.com/nxtbooks/ieee/spectrum_na_0107
https://www.nxtbookmedia.com