Deep Learning (CNN) in Raspberry Pi 3

Just to share some things I did with my small raspberry pi 3.. I was looking for a way to do some deep learning stuff with the raspberry pi 3 – in particular using the awesome Convolutional Neural Network (CNN) architectures for some real-time object recognition of any movement in a fixed background scene.

The Rpi 3 got these specs:

Processor: 1.2 Ghz  / RAM: 1.0 Gig / has ethernet, 4 USB ports, etc. and can be fitted with the standard Rpi camera module

When I searched the net for possible CNN options given an Rpi hardware, I got some hints here and there that it is possible to install the Caffe library in Rpi (Raspbian OS). The downside is that with the standard BVLC Caffe reference model , one image takes a very long 20s!  just to process.

Several other websites suggested using Pete Warden’s customized Imagenet CNN. I followed Pete’s blog and installed the DeepBeliefSDK. Processing lowered down to 2-3s / image. But the downside here is that Pete does not provide any other functionality to train new networks (and I only want 4 classes ! – person, cat, bird, and plant not the whole 1000 class Imagenet dataset).

Good thing is, I got a bit lucky this time around

Check out SQUEEZENET by Iandola, Moskewicz and Ashraf (2016). It’s already in the Caffe Model Zoo

@article{SqueezeNet,
    Author = {Forrest N. Iandola and Matthew W. Moskewicz and Khalid Ashraf and Song Han and William J. Dally and Kurt Keutzer},
    Title = {SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and $<$1MB model size},
    Journal = {arXiv:1602.07360},
    Year = {2016}
}

As per Squeezenet creators, they have the same accuracy in AlexNet but with a very small network (of around 1-4 Megabytes)

And in the Rpi 3, a Squeezenet CNN classifies an image (using the CPU) at around 2 seconds! – It’s almost as fast as the Haar cascade classifier.

I trained the Squeezenet on my 10,000+ image dataset, and accuracy is 95%. – just sweet.

 

 

Advertisements