A fun way to learn about Watson Visual Recognition and creating your own classifier, is with
Lego 42055, and a Raspberry Pi.
What you can notice in the video is
- The time it takes to identify a brick, we have 12 bricks, that are transported in 16 seconds. It took 40 seconds more to finish the recognition proces
- Not all identifications are correct
We can gain some performance by tighter coupling, but the measurements show that I takes up to 2 seconds to classify an image.
This is the roundtrip to the Watson Cloud Services.
This article helped in traning the classifier, I first did a couple of rounds where I only took the pictures and collected them for trainingpurposes.
I made sure the lighting and camera distance stayed (more or less) the same.
First I had hoped to keep op with the fysical world and show live icons.
In the end, I decided to demonstrated the recognition skills by photographing the order in which the bricks were put on the transport belt.
I have trained Watson for 6 different bricks.
By grabbing enough frames for each picture (ca. 35) AND a lot of negatives (ca. 150) I found the identification results to be above 98% !
I used the official Lego brick-part numbers as labels (and named the zip files accordingly to keep things consistent)
When you use the Watson Java SDK the code for training is a simple as this:
VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_20);
String classifier = "legos_123";
ClassifierOptions createOptions = new ClassifierOptions.Builder()
.addClass("300321", new File(basePath+"\\300321.zip"))
.addClass("303921", new File(basePath+"\\303921.zip"))
.addClass("300324", new File(basePath+"\\300324.zip"))
.addClass("366024", new File(basePath+"\\366024.zip"))
.addClass("4161674", new File(basePath+"\\4161674.zip"))
.addClass("4211637", new File(basePath+"\\4211637.zip"))
VisualClassifier legos = service.updateClassifier(classifier, createOptions).execute();