I’ve received a number of emails from PyImageSearch readers who are interested in performing deep learning in their Raspberry Pi. Most of the questions go something like this:
Hey Adrian, thanks for all the tutorials on deep learning. You’ve really made deep learning accessible and easy to understand. I have a question: Can I do deep learning on the Raspberry Pi? What are the steps?
And almost always, I have the same response:
The question really depends on what you mean by “do”. You should never be training a neural network on the Raspberry Pi — it’s far too underpowered. You’re much better off training the network on your laptop, desktop, or even GPU (if you have one available).
That said, you can deploy efficient, shallow neural networks to the Raspberry Pi and use them to classify input images.
Again, I cannot stress this point enough:
You should not be training neural networks on the Raspberry Pi (unless you’re using the Pi to do the “Hello, World” equivalent of neural networks — but again, I would still argue that your laptop/desktop is a better fit).
With the Raspberry Pi there just isn’t enough RAM.
The processor is too slow.
And in general it’s not the right hardware for heavy computational processes.
Instead, you should first train your network on your laptop, desktop, or deep learning environment.
Once the network is trained, you can then deploy the neural network to your Raspberry Pi.
In the remainder of this blog post I’ll demonstrate how we can use the Raspberry Pi and pre- trained deep learning neural networks to classify input images.
Looking for the source code to this post?
Jump Right To The Downloads SectionDeep learning on the Raspberry Pi with OpenCV
When using the Raspberry Pi for deep learning we have two major pitfalls working against us:
- Restricted memory (only 1GB on the Raspberry Pi 3).
- Limited processor speed.
This makes it near impossible to use larger, deeper neural networks.
Instead, we need to use more computationally efficient networks with a smaller memory/processing footprint such as MobileNet and SqueezeNet. These networks are more appropriate for the Raspberry Pi; however, you need to set your expectations accordingly — you should not expect blazing fast speed.
In this tutorial we’ll specifically be using SqueezeNet.
What is SqueezeNet?
SqueezeNet was first introduced by Iandola et al. in their 2016 paper, SqueezeNet: AlexNet-level accuracy with 50x few parameters and <0.5MB model size.
The title alone of this paper should pique your interest.
State-of-the-art architectures such as ResNet have model sizes that are >100MB. VGGNet is over 550MB. AlexNet sits in the middle of this size range with a model size of ~250MB.
In fact, one of the smaller Convolutional Neural Networks used for image classification is GoogLeNet at ~25-50MB (depending on which version of the architecture is implemented).
The real question is: Can we go smaller?
As the work of Iandola et al. demonstrates, the answer is: Yes, we can decrease model size by applying a novel usage of 1×1 and 3×3 convolutions, along with no fully-connected layers. The end result is a model weighing in at 4.9MB, which can be further reduced to < 0.5MB by model processing (also called “weight pruning” and “sparsifying a model”).
In the remainder of this tutorial I’ll be demonstrating how SqueezeNet can classify images in approximately half the time of GoogLeNet, making it a reasonable choice when applying deep learning on your Raspberry Pi.
Interested in learning more about SqueezeNet?
If you’re interested in learning more about SqueezeNet, I would encourage you to take a look at my new book, Deep Learning for Computer Vision with Python.
Inside the ImageNet Bundle, I:
- Explain the inner workings of the SqueezeNet architecture.
- Demonstrate how to implement SqueezeNet by hand.
- Train SqueezeNet from scratch on the challenging ImageNet dataset and replicate the original results by Iandola et al.
Go ahead and take a look — I think you’ll agree with me when I say that this is the most complete deep learning + computer vision education you can find online.
Running a deep neural network on the Raspberry Pi
The source code from this blog post is heavily based on my previous post, Deep learning with OpenCV.
I’ll still review the code in its entirety here; however, I would like to refer you over to the previous post for a complete and exhaustive review.
To get started, create a new file named pi_deep_learning.py
, and insert the following source code:
# import the necessary packages import numpy as np import argparse import time import cv2
Lines 2-5 simply import our required packages.
From there, we need to parse our command line arguments:
# construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", required=True, help="path to input image") ap.add_argument("-p", "--prototxt", required=True, help="path to Caffe 'deploy' prototxt file") ap.add_argument("-m", "--model", required=True, help="path to Caffe pre-trained model") ap.add_argument("-l", "--labels", required=True, help="path to ImageNet labels (i.e., syn-sets)") args = vars(ap.parse_args())
As is shown on Lines 9-16 we have four required command line arguments:
--image
: The path to the input image.--prototxt
: The path to a Caffe prototxt file which is essentially a plaintext configuration file following a JSON-like structure. I cover the anatomy of Caffe projects in my PyImageSearch Gurus course.--model
: The path to a pre-trained Caffe model. As stated above, you’ll want to train your model on hardware which packs much more punch than the Raspberry Pi — we can, however, leverage a small, pre-existing model on the Pi.--labels
: The path to class labels, in this case ImageNet “syn-sets” labels.
Next, we’ll load the class labels and input image from disk:
# load the class labels from disk rows = open(args["labels"]).read().strip().split("\n") classes = [r[r.find(" ") + 1:].split(",")[0] for r in rows] # load the input image from disk image = cv2.imread(args["image"])
Go ahead and open synset_words.txt
found in the “Downloads” section of this post. You’ll see on each line/row there is an ID and class labels associated with it (separated by commas).
Lines 20 and 21 simply read in the labels file line-by-line (rows
) and extract the first relevant class label. The result is a classes
list containing our class labels.
Then, we utilize OpenCV to load the image on Line 24.
Now we’ll make use of OpenCV 3.3’s Deep Neural Network (DNN) module to convert the image
to a blob
as well as to load the model from disk:
# our CNN requires fixed spatial dimensions for our input image(s) # so we need to ensure it is resized to 227x227 pixels while # performing mean subtraction (104, 117, 123) to normalize the input; # after executing this command our "blob" now has the shape: # (1, 3, 227, 227) blob = cv2.dnn.blobFromImage(image, 1, (227, 227), (104, 117, 123)) # load our serialized model from disk print("[INFO] loading model...") net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
Be sure to make note of the comment preceding our call to cv2.dnn.blobFromImage
on Line 31 above.
Common choices for width and height image dimensions inputted to Convolutional Neural Networks include 32 × 32, 64 × 64, 224 × 224, 227 × 227, 256 × 256, and 299 × 299. In our case we are pre-processing (normalizing) the image to dimensions of 227 x 227 (which are the image dimensions SqueezeNet was trained on) and performing a scaling technique known as mean subtraction. I discuss the importance of these steps in my book.
Note: You’ll want to use 224 x 224 for the blob size when using SqueezeNet and 227 x 227 for GoogLeNet to be consistent with the prototxt definitions.
We then load the network from disk on Line 35 by utilizing our prototxt
and model
file path references.
In case you missed it above, it is worth noting here that we are loading a pre-trained model. The training step has already been performed on a more powerful machine and is outside the scope of this blog post (but covered in detail in both PyImageSearch Gurus and Deep Learning for Computer Vision with Python).
Now we’re ready to pass the image through the network and look at the predictions:
# set the blob as input to the network and perform a forward-pass to # obtain our output classification net.setInput(blob) start = time.time() preds = net.forward() end = time.time() print("[INFO] classification took {:.5} seconds".format(end - start)) # sort the indexes of the probabilities in descending order (higher # probabilitiy first) and grab the top-5 predictions preds = preds.reshape((1, len(classes))) idxs = np.argsort(preds[0])[::-1][:5]
To classify the query blob
, we pass it forward through the network (Lines 39-42) and print out the amount of time it took to classify the input image (Line 43).
We can then sort the probabilities from highest to lowest (Line 47) while grabbing the top five predictions
(Line 48).
The remaining lines (1) draw the highest predicted class label and corresponding probability on the image, (2) print the top five results and probabilities to the terminal, and (3) display the image to the screen:
# loop over the top-5 predictions and display them for (i, idx) in enumerate(idxs): # draw the top prediction on the input image if i == 0: text = "Label: {}, {:.2f}%".format(classes[idx], preds[0][idx] * 100) cv2.putText(image, text, (5, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2) # display the predicted label + associated probability to the # console print("[INFO] {}. label: {}, probability: {:.5}".format(i + 1, classes[idx], preds[0][idx])) # display the output image cv2.imshow("Image", image) cv2.waitKey(0)
We draw the top prediction and probability on the top of the image (Lines 53-57) and display the top-5 predictions + probabilities on the terminal (Lines 61 and 62).
Finally, we display the output image on the screen (Lines 65 and 66). If you are using SSH to connect with your Raspberry Pi this will only work if you supply the -X
flag for X11 forwarding when SSH’ing into your Pi.
To see the results of applying deep learning on the Raspberry Pi using OpenCV and Python, proceed to the next section.
Raspberry Pi and deep learning results
We’ll be benchmarking our Raspberry Pi for deep learning against two pre-trained deep neural networks:
- GoogLeNet
- SqueezeNet
As we’ll see, SqueezeNet is much smaller than GoogLeNet (5MB vs. 25MB, respectively) and will enable us to classify images substantially faster on the Raspberry Pi.
To run pre-trained Convolutional Neural Networks on the Raspberry Pi use the “Downloads” section of this blog post to download the source code + pre-trained neural networks + example images.
From there, let’s first benchmark GoogLeNet against this input image:
As we can see from the output, GoogLeNet correctly classified the image as “barbershop” in 1.7 seconds:
$ python pi_deep_learning.py --prototxt models/bvlc_googlenet.prototxt \ --model models/bvlc_googlenet.caffemodel --labels synset_words.txt \ --image images/barbershop.png [INFO] loading model... [INFO] classification took 1.7304 seconds [INFO] 1. label: barbershop, probability: 0.70508 [INFO] 2. label: barber chair, probability: 0.29491 [INFO] 3. label: restaurant, probability: 2.9732e-06 [INFO] 4. label: desk, probability: 2.06e-06 [INFO] 5. label: rocking chair, probability: 1.7565e-06
Let’s give SqueezeNet a try:
$ python pi_deep_learning.py --prototxt models/squeezenet_v1.0.prototxt \ --model models/squeezenet_v1.0.caffemodel --labels synset_words.txt \ --image images/barbershop.png [INFO] loading model... [INFO] classification took 0.92073 seconds [INFO] 1. label: barbershop, probability: 0.80578 [INFO] 2. label: barber chair, probability: 0.15124 [INFO] 3. label: half track, probability: 0.0052873 [INFO] 4. label: restaurant, probability: 0.0040124 [INFO] 5. label: desktop computer, probability: 0.0033352
SqueezeNet also correctly classified the image as “barbershop”…
…but in only 0.9 seconds!
As we can see, SqueezeNet is significantly faster than GoogLeNet — which is extremely important since we are applying deep learning to the resource constrained Raspberry Pi.
Let’s try another example with SqueezeNet:
$ python pi_deep_learning.py --prototxt models/squeezenet_v1.0.prototxt \ --model models/squeezenet_v1.0.caffemodel --labels synset_words.txt \ --image images/cobra.png [INFO] loading model... [INFO] classification took 0.91687 seconds [INFO] 1. label: Indian cobra, probability: 0.47972 [INFO] 2. label: leatherback turtle, probability: 0.16858 [INFO] 3. label: water snake, probability: 0.10558 [INFO] 4. label: common iguana, probability: 0.059227 [INFO] 5. label: sea snake, probability: 0.046393
However, while SqueezeNet is significantly faster, it’s less accurate than GoogLeNet:
$ python pi_deep_learning.py --prototxt models/squeezenet_v1.0.prototxt \ --model models/squeezenet_v1.0.caffemodel --labels synset_words.txt \ --image images/jellyfish.png [INFO] loading model... [INFO] classification took 0.92117 seconds [INFO] 1. label: bubble, probability: 0.59491 [INFO] 2. label: jellyfish, probability: 0.23758 [INFO] 3. label: Petri dish, probability: 0.13345 [INFO] 4. label: lemon, probability: 0.012629 [INFO] 5. label: dough, probability: 0.0025394
Here we see the top prediction by SqueezeNet is “bubble”. While the image may appear to have bubble-like characteristics, the image is actually of a “jellyfish” (which is the #2 prediction from SqueezeNet).
GoogLeNet on the other hand correctly reports “jellyfish” as the #1 prediction (with the sacrifice of processing time):
$ python pi_deep_learning.py --prototxt models/bvlc_googlenet.prototxt \ --model models/bvlc_googlenet.caffemodel --labels synset_words.txt \ --image images/jellyfish.png [INFO] loading model... [INFO] classification took 1.7824 seconds [INFO] 1. label: jellyfish, probability: 0.53186 [INFO] 2. label: bubble, probability: 0.33562 [INFO] 3. label: tray, probability: 0.050089 [INFO] 4. label: shower cap, probability: 0.022811 [INFO] 5. label: Petri dish, probability: 0.013176
What's next? We recommend PyImageSearch University.
84 total classes • 114+ hours of on-demand code walkthrough videos • Last updated: February 2024
★★★★★ 4.84 (128 Ratings) • 16,000+ Students Enrolled
I strongly believe that if you had the right teacher you could master computer vision and deep learning.
Do you think learning computer vision and deep learning has to be time-consuming, overwhelming, and complicated? Or has to involve complex mathematics and equations? Or requires a degree in computer science?
That’s not the case.
All you need to master computer vision and deep learning is for someone to explain things to you in simple, intuitive terms. And that’s exactly what I do. My mission is to change education and how complex Artificial Intelligence topics are taught.
If you're serious about learning computer vision, your next stop should be PyImageSearch University, the most comprehensive computer vision, deep learning, and OpenCV course online today. Here you’ll learn how to successfully and confidently apply computer vision to your work, research, and projects. Join me in computer vision mastery.
Inside PyImageSearch University you'll find:
- ✓ 86 courses on essential computer vision, deep learning, and OpenCV topics
- ✓ 86 Certificates of Completion
- ✓ 115+ hours of on-demand video
- ✓ Brand new courses released regularly, ensuring you can keep up with state-of-the-art techniques
- ✓ Pre-configured Jupyter Notebooks in Google Colab
- ✓ Run all code examples in your web browser — works on Windows, macOS, and Linux (no dev environment configuration required!)
- ✓ Access to centralized code repos for all 540+ tutorials on PyImageSearch
- ✓ Easy one-click downloads for code, datasets, pre-trained models, etc.
- ✓ Access on mobile, laptop, desktop, etc.
Summary
Today, we learned how to apply deep learning on the Raspberry Pi using Python and OpenCV.
In general, you should:
- Never use your Raspberry Pi to train a neural network.
- Only use your Raspberry Pi to deploy a pre-trained deep learning network.
The Raspberry Pi does not have enough memory or CPU power to train these types of deep, complex neural networks from scratch.
In fact, the Raspberry Pi barely has enough processing power to run them — as we’ll find out in next week’s blog post you’ll struggle to get a reasonable frames per second for video processing applications.
If you’re interested in embedded deep learning on low cost hardware, I’d consider looking at optimized devices such as NVIDIA’s Jetson TX1 and TX2. These boards are designed to execute neural networks on the GPU and provide real-time (or as close to real-time as possible) classification speed.
In next week’s blog post, I’ll be discussing how to optimize OpenCV on the Raspberry Pi to obtain performance gains by upwards of 100% for object detection using deep learning.
To be notified when this blog post is published, just enter your email address in the form below!
Download the Source Code and FREE 17-page Resource Guide
Enter your email address below to get a .zip of the code and a FREE 17-page Resource Guide on Computer Vision, OpenCV, and Deep Learning. Inside you'll find my hand-picked tutorials, books, courses, and libraries to help you master CV and DL!
Andrey
Nice detailed post. Thank you.
Adrian Rosebrock
Thanks Andrey!
Flávio Rodrigues
Hi, Dr. Adrian! Should not the size of the input image be 227×227 as reported in the prototxt file? And just to be perfect as always, there is a typo on line “Train SqueezeNet from scratch on the challenging ImageNetd ataset and replicate the original results by Iandola et al.” 😉 Thanks a lot for your posts!
Adrian Rosebrock
Thank you for reporting the typo, Flávio! I have fixed it now.
As for SqueezeNet, yes, it should be 227×227 as that is what the prototxt reports. I have updated that typo as well.
Ashutosh Dubey
does your book “deep learning for computer vision” is useful to work with raspberry pi?
Adrian Rosebrock
You can go through the vast majority of the Starter Bundle of Deep Learning for Computer Vision with Python on the Raspberry Pi, but not the Practitioner Bundle or ImageNet Bundle.
As I mentioned in the blog post you should really be using your laptop or desktop if you intend to train neural networks with scratch.
Cristian Benglenok
if I set a cluster with 2 or 4 raspbery pi 3, will increase the processing speed considerably? if we use it to deploy a pre-trained deep learning network.
Adrian Rosebrock
Not really, because at that point you’ll be dealing with network I/O latency at inference time. You’ll need a faster system if you need quicker classifications.
fariborz
hi Adrian
tanx alot
nice post
i need deep learning with raspberry pi
please make a tutorial for Drowsiness detection with raspberry pi.
i do drowsiness project with raspberry but it is lagy and very slow
Adrian Rosebrock
I will be doing a Raspberry Pi + drowsiness detector later this month (October 2017).
fariborz
wow nice tanx a lot
Kiran
That’s so awesome! I can’t believe we have made it this far with all the CV blogs! The Pi community is so big and getting bigger and bigger with DNNs. I wanted to know if there’s a separate webpage on your website where people who follow your blog could benchmark and share all their Pi’s performance ratings for CNNs! Looking forward to your upcoming post on running it on live stream! I pity those Pi’s taking so much stress! ha ha 😛
Adrian Rosebrock
Hi Kiran — I don’t have any a page dedicated where readers can share their benchmarks using deep learning and the Raspberry Pi, but I’ll definitely consider this for the future.
aditya
Hello Sir Please write a blog on how to make a model for object recognization in image steps to train the model and what algorithm using deep learning please please make such tut as you have made a tutorial for object detection but it has pre-trained model but i want to learn how to train manually the images soo make such blog tut…
As you have told before that this is available in your book but really i don’t have enough money to buy your book but i always read your blog and gain knoweldge. I use collage resources to implement your code and i am really intrested in learning so i work hard but i don’t have enough money to get the paid course but your blog has helped me a lot soo thank you very much…
Aleksandr Rybnikov
Thank you, Adrian! Excellent job! I just want to add that model’s size isn’t an exhausting way to estimate inference time. For example, ENet architectire has ~10MB as all weights, but takes a lot of computations and time to apply these weights. OpenCV’s dnn has functions to get FLOPs for model without inference.
Also recently I added new face detector to the dnn. It’s ResNet-based SSD and I trained it on some open dataset full of faces. It works faster than real-time on i7-6700k and according to tests it’s better than casscades-based one. Maybe this infirmation will be interesting for you
Adrian Rosebrock
Hi Aleksandr — you’re absolutely right, examining model size is not an exact way to measure inference time. I was instead referring to the limited RAM available on the Raspberry Pi and that users need to be careful not to exhaust this memory.
The new ResNet-based SSD face detector sounds very interesting as well! I’ll be sure to take a look at this.
Abrie
Hi Adrian. Thanks a lot for these tutorials.
Will next weeks blog post cover how to detect objects from a live video stream on the Raspberry Pi and Picam module?
Kind regards
Abrie
Adrian Rosebrock
Hi Abrie — next week’s blog post will be on optimizing OpenCV and milking every last bit of performance out of it. The following week will then cover deep learning-based object detection on the Raspberry Pi.
Doug
THANK YOU! I downloaded the .py source for this squeezenet demo.. After building python3.6 and then opencv3.3 with tinydnn needed for dnn in cv (or was it?) all in a docker (and not on a Pi), this demo.tutorial worked for me first time. I am now tempted to take the twenty-one day course.
Adrian Rosebrock
Nice job, Doug!
Adrian Rosebrock
Please see this post where discusses the SSD object detector that includes a “person” class.
memeka
Can the googlenet and squeezenet models be used for object detection too (not classification), or do I need different models?
Thanks.
Adrian Rosebrock
No, you cannot swap out arbitrary networks. The network needs to follow a certain object detection framework such as SSD, R-CNN, YOLO, etc. Networks train for strictly image classification cannot be directly used for object detection to predict the bounding box around an object in an image. I’ll be covering how to train your own custom object detection networks inside Deep Learning for Computer Vision with Python.
memeka
Do you know of squeezenet or googlenet (or resnet) ssd pretrained models?
I wanted to see the speed difference between them on my board 🙂
Rolba
In general, you should:
Never use your Raspberry Pi to train a neural network.
Only use your Raspberry Pi to deploy a pre-trained deep learning network.
I only tried once just for fun:P.
But being serious this is very usefull lesson lerned. Imagine you have to count something in the field or what so ever. Something – somewhere without electricity plugin, no IP connection. Middle of Alaska! R-pi is very good choice to power it from solar panel (~5 wats), plugin camera, load pre-trained dnn and classify. Spend 35 bucks on sale and there you go!
But if you have more money you can always play with very nice Nvidia Jestson platform ;).
But it’s always a matter of costs. You can always have your R-pi and connect it to Irirdium if you have to collect a lot of data and make a lot of dnn operations on server.
Take care.
Rolba
Adrian Rosebrock
The Raspberry Pi is an extremely versatile tool, you’re absolutely right 🙂
Sanjaya Kumar Das
I am getting this error !!
Unable to init server: Could not connect: Connection refused
(Image:1363): Gtk-WARNING **: cannot open display:
Adrian Rosebrock
Are you SSH’ing into your Raspberry Pi? If so, make sure you enable X11 forwarding:
$ ssh -X pi@your_ip_address
Eric
Hello , Tried running the script but i keep getting this error :
[INFO] loading model…
[INFO] starting process…
[INFO] starting video stream…
VIDIOC_QUERYCTRL: Input/output error
Illegal instruction
Eric
additional info : i’m using a web cam to get the video stream
Adrian Rosebrock
Hey Eric — based on your error, it seems that OpenCV cannot access your webcam. I assume this is a USB webcam? If so, what model of webcam?
Ayush Goel
I am facing a similar error. When I initialize the VideoCapture object with the camera index, I get the error ‘VIDIOC_QUERYCTRL: Input/output error’.
I tested the camera using a Video Calling app on RPi and the camera works fine on that.
Adrian Rosebrock
Are you using a USB camera? Or the Raspberry Pi camera module?
David Tan
Which python do you use in your tutorial, 2.7 or 3.4,3,5,3.6?
Thanks
Adrian Rosebrock
I primarily use Python 3.4 and Python 3.5 now, but earlier tutorials use Python 2.7 as well. I try to use all of them.
Vishruth
Hi m getting this error
$ python pi_deep_learning.py –prototxt models/squeezenet_v1.0.prototxt \
> –model models/squeezenet_v1.0.caffemodel –labels synset_words.txt \
> –image images/barbershop.png
Traceback (most recent call last):
File “pi_deep_learning.py”, line 35, in
blob = cv2.dnn.blobFromImage(image, 1, (224, 224), (104, 117, 123))
AttributeError: ‘module’ object has no attribute ‘dnn’
Adrian Rosebrock
Make sure you are running OpenCV 3.3+. The “dnn” module was not added until OpenCV 3.3.
Bruce Lunde
THis is too cool. I followed your tutorial on installing openCV on Raspberry Pi, then ran this code against that setup, and it runs, so great, thanks for publishing. I have your Practical CV bundle from 2015, and will be using this Pi to learn on. DO you have a recommended VM for learning on a laptop?
Adrian Rosebrock
Hey Bruce! I’m so happy you found the tutorial helpful, that’s awesome. I have a VM included in my new book, Deep Learning for Computer Vision with Python that would be suitable for you to run on your laptop and use it for learning. Let me know if you have any questions about it.
Abdul Basit Aftab
Can you please tell how to train a squeezeNet network for our own set of images ?
I am making a currency detector using raspberry pi and opencv , yoour help will be much appreciated
Adrian Rosebrock
I have a number of tutorials on how to train your own custom CNNs. I would suggest starting with this introductory post to help you get started. If you would like to train SqueezeNet totally from scratch be sure to take a look at my book, Deep Learning for Computer Vision with Python where I explain (and provide code) how to train SqueezeNet on your own custom data.
Mitul
Great Tutorial!
Is there a way to improve the performance? I used the Intel Neural Stick but it has many limitations.
Is it possible to use cloud computing with raspberry pi?
Adrian Rosebrock
You could use cloud computing but keep in mind there will be latency between the Pi uploading the image to the cloud, the cloud processing the image, and then the cloud sending the result back.
h1ma
imho, GoogleNet more accurate than SqueezeNet, but loads the cpu on all 100500% :o)
Lee
Hey Adrian,
Thanks for your post! I was wondering if it is possible to train a simple cnn from scratch for an rpi 3b/4 such that inference/prediction performs real time classification/detection?
If so, what architecture would fulfil this? Thank you!
Adrian Rosebrock
I don’t recommend training a network on a RPi. Train it on your laptop, desktop, or DL rig, then transfer the model to the RPi.
Aditya Singh
Hi Adrian, I would like to run a network such as squeezenet or googlenet on a raspberry pi zero wireless, it has 512 MB RAM and 1GHz of CPU processing power, will it be able to run such a classification network on it? I mainly want to classify whether a person is there in the picture, I don’t need object detection (person detection and only classification as of now).
Also, with the release of raspberry pi 4 B with 4GB and 2 GB of RAM and Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz processor, do you think it’d be okay running models such as full-yolov3, retina-net and other such models, and even perform object detection on the pi.
Adrian Rosebrock
Hey Aditya — take a look at Raspberry Pi for Computer Vision where I show you how to run popular image classification and object detection networks on the Raspberry Pi.
Lakshay Agarwal
Hey.. Your post was very helpful
Can you suggest how to use picam for real time image classification using deep learning and raspberry pi as an extension to your post.
Adrian Rosebrock
That exact topic is covered in my book, Raspberry Pi for Computer Vision.