MathWorks - Mobile View
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
MathWorks
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out

Videos and Webinars

  • MathWorks
  • Videos
  • Videos Home
  • Search
  • Videos Home
  • Search
  • Contact sales
  • Trial software
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Image Classification on ARM CPU: SqueezeNet on Raspberry Pi

Ram Cherukuri, MathWorks

See a demonstration of image classification using deep learning on a Raspberry Pi™ from MATLAB® using the Raspberry Pi support package. MATLAB provides a complete integrated workflow for engineers and scientists to explore, prototype, and deploy deep learning algorithms in a familiar development environment with built-in higher-level apps and libraries.

Using MATLAB Coder™, you can generate C++ code for the complete inference pipeline with image acquisition, preprocessing, and postprocessing around a trained network and deploy to any ARM® Cortex-A based platform, such as the Raspberry Pi or NXP™ i.MX family of processors.

Hi, I am Ram Cherukuri, product manager here at MathWorks, and welcome to another edition of deep learning on Raspberry Pi, this time using it for image classification using squeezenet.

In this video, I hope to show how easily you can take your MATLAB algorithm and test it and validate it using live I/O within MATLAB, test it on the target Raspberry Pi using processor-in-loop simulation before deploying it as a standalone application, without needing to write any additional code in C or C++.

I decided to pick image classification as an example of machine learning and deep learning application for a couple of reasons:

  • It’s one of the fundamental video and image processing tasks in many such applications from video surveillance to automated driving and so on.
  • And it’s very relevant to embedded deployment, which means it should work in real time on a target processor.

You can refer to a lot more resources on machine learning and deep learning in MATLAB on mathworks.com.

Speaking of embedded processors, I chose Raspberry Pi for another reason other than it is fun and accessible. It is based on an Arm Cortex A, similar to most other vision-based processors out there.

MATLAB Coder enables you to generate code and deploy your application to any Arm Cortex A based processor that supports Neon instructions.

You get optimal performance because the generated code calls into Arm’s Compute Library, which provides low-level functions optimized for Arm’s CPU and GPU platforms.

Please refer to the link below to learn more about the Compute Library.

In previous videos, we covered deployment aspects with examples such as pedestrian detection and in this video, we will focus on hardware-in-the-loop testing and validation.

Here is our MATLAB algorithm that takes in an input image, does some resizing as a preprocessing step, uses trained squeezenet for inference, and then performs post-processing to identify and display the top five classifications.

Here is my test script that I will use to run through the example.

Let’s first run this section of code to see what the algorithm does on the input image within MATLAB. You can see that it gives us the top five classifications for the things in our input image.

Now, I want to test and validate my algorithm with some live data. Here I am setting up a connection to a Raspberry Pi and I can use the webcam attached to it to get the live feed from the camera and run inference on it in MATLAB – pretty straightforward.

Please make a note to download the free Raspberry Pi support package to try this out.

In addition, if you have MATLAB Coder, you can also generate code and deploy it on the Raspberry Pi.

How about we verify the generated code with the processor-in-loop, so we can use MATLAB as our test bench to pass the input to the application on the target and get the result back into MATLAB for comparison?

Once code gen is complete, we get this MEX file that I can use to run the application on the Raspberry Pi. Using the same test input, we are running the image classification on the Raspberry Pi and we get the classification results. You can do more detailed verification by comparing the outputs, etc., but you get the point.

Throughout the example we did not have to write any C or C++ code. However, if you like to use any custom libraries such as OpenCV, you can always manually integrate the generated code and write a custom main file to compile into a bigger application.

Please refer to the links below to try out this example for yourself and to download the necessary support packages.

Related Products

  • MATLAB Coder
  • Deep Learning Toolbox
  • Embedded Coder
  • GPU Coder

Learn More

Deep Learning Inference for Object Detection on Raspberry Pi (2:04)
Raspberry Pi Support from MATLAB
Deep Learning Prediction with ARM Compute
Related Information
Get started with deep learning for your application

Feedback

Featured Product

MATLAB Coder

  • Request Trial
  • Get Pricing

Up Next:

4:21
Accelerate Image Compression Algorithm Using MATLAB Coder

Related Videos:

48:36
ARM Cortex-A, -R, -M Optimized Code Generation using MATLAB...
3:36
Wine Classification with Neural Net Pattern Recognition App
6:48
Using Simulink to Program Raspberry Pi for Image Inversion
33:03
Rapid Control Prototyping for Permanent Magnet Synchronous...

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contact sales
  • Trial software

Explore Products

  • MATLAB
  • Simulink
  • Student Software
  • Hardware Support
  • File Exchange

Try or Buy

  • Downloads
  • Trial Software
  • Contact Sales
  • Pricing and Licensing
  • How to Buy

Learn to Use

  • Documentation
  • Tutorials
  • Examples
  • Videos and Webinars
  • Training

Get Support

  • Installation Help
  • Answers
  • Consulting
  • License Center
  • Contact Support

About MathWorks

  • Careers
  • Newsroom
  • Social Mission
  • Contact Sales
  • About MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Discover…

  • Select a Web Site United States
  • Patents
  • Trademarks
  • Privacy Policy
  • Preventing Piracy
  • Application Status

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Join the conversation