Edge AI with Raspberry Pi at GHC19, Grace Hopper Celebration of Women in Computing
Hello deep learning enthusiasts! My name is Sara Nadeau, and I am excited to be writing this guest blog post on behalf of the MathWorks Grace Hopper Celebration team! The Grace Hopper Celebration is the world's largest gathering of women technologists. MathWorks was a platinum sponsor of GHC19 and a partner of AnitaB.org. The MathWorks GHC team had 5 opportunities to lead sessions at GHC19 with a talk, a panel, and three workshops.
The post covers the Edge AI with Raspberry Pi workshop developed by Jaya Shankar, software development manager of the deep learning code generation team; Louvere Walker-Hannon, application engineer working with customers on deep learning and data analytics; and Penny Anderson, director of software engineering. The workshop was part of the brand new hardware track added to the conference in 2019.
Preparing the Workshop
In spaces where software starts blending to hardware, you hear this all the time: "Hardware is hard!" As an engineer with a background in electrical engineering, I always cringe at the thought that this refrain might discourage someone from trying to deploy their designs in different environments or even explore the beauty of analog circuitry. However, I must concede that there is one place this is undeniably true: preparation and logistics! The workshop team relied on a small army of behind-the-scenes volunteers which included myself, several other members of the MathWorks GHC team, and many makers at MathWorks. Working with hardware differs from software in that each workshop setup is physically unique and must be tested and set up individually. The team hosted many board setup and exercise bash parties. Here's a photo from one.From left to right, you see Chinmayi Lanka, a quality engineer who helped immensely in the exercise code development and testing; Sarah Mohamed, a software engineer on the MathWorks GHC team and presenter for the Pocket AI and IoT workshop; myself, having a lovely hair day; and Louvere, all holding boards we'd set up and tested. Even so, the task of setting up the hardware was made much simpler with the help of Reeno Joseph, a software developer on the embedded targets team in Bangalore who wrote scripts to help minimize the number of steps each volunteer had to perform to set up a single board. In addition to preparing the physical boards, the hardware workshop presented an interesting communication challenge: we needed to guide participants - regardless of their hardware experience - through the process of operating a Raspberry Pi board in headless mode from their own laptops. As the technical writer on the team, I drafted and tested several iterations of workshop instructions. The final product was helpful enough for an engineer from IBM to stay back after the workshop for the purpose of thanking us for the instructions.
Transporting the Workshop
GHC19 occurred in Orlando, which meant the MathWorks GHC team had to negotiate the logistics of transporting all the required hardware from Natick, MA. How much hardware could we transport, and how would we do it? What kind of power access will be available in the room? Can we run the Raspberry Pi boards from battery banks? The logistical challenges were seemingly endless, and yet the Edge AI team managed to pull it off without a hitch, shipping 80 Raspberry Pi boards to Florida and then testing each and every board ahead of the workshop session. Here's Penny, toting a few of the boxes of Raspberry Pis, Ethernet cables, power banks, USB cables, and Ethernet adapters provided for the workshop. Even after we got all the hardware to Orlando without damaging a single board, the team still had to set up the hardware configuration for all 80 boards before the attendees started arriving to the workshop room. All available team members worked quickly to prepare the room. The workshop filled up in preregistration, and there were hardly any open seats on the day it was delivered. Excited participants performed face and age detection on images first in MATLAB Online and then using generated code deployed on the Raspberry Pi.Face and Age Detection in MATLAB
To start the workshop and explore the problem space, all participants performed face and age detection for an image, specifically a picture of the GHC18 Deep Learning and IoT workshop team, which also features Louvere.im = imread('GHC18.jpg'); im = imresize(im, [416,416]); out = detectAge(im); figure imshow(out);The age detection network was trained using a relatively small data set of celebrity images. The focus of the Edge AI with Raspberry Pi workshop is to explain deep learning and hardware concepts through a fun demo. Still, it's interesting and fun to consider the ways in which the training data affect the classification results. As you may have guessed, the deep learning magic for face and age detection happens in the detectAge function. The function loads a pre-trained YOLOv2 network to detect faces in the input image.
faceDetector = coder.loadDeepLearningNetwork('trained_face_detector_yolov2_mobilenetv2.mat'); %... im = imresize(in,[416,416]); [face_boxes,~,labels1] = faceDetector.detect(im,'Threshold',0.5); %...The detectAge function then feeds the detected faces into a MobileNetV2 deep learning classifier to predict the age for each face detected in the image.
ageDetector = coder.loadDeepLearningNetwork('ageDetector_Mobilenetv2.mat'); %... for k = 1:size(face_boxes,1) % Run age classifier on each detected face face_box_pt = face_boxes(k,:); ymin = face_box_pt(1,2); ymax = ymin + face_box_pt(1,4); xmin = face_box_pt(1,1); xmax = xmin + face_box_pt(1,3); face = im(ymin:ymax, xmin:xmax); faceout(1:128,1:128,:) = imresize(face, [128,128]); pout = ageDetector.predict(faceout); % Compute age as weighted sum using returned probabilities ages = [0:100]; p_age = round(sum((ages+1).*pout)-1); %... endParticipants had fun running the MATLAB code on their own images, and the workshop quickly moved on to discuss how to move the network to the edge.
Deploying the Trained Network on the Edge
Next up in the workshop was a discussion of code generation as a key tool for deploying deep learning networks. Due to time constraints, the participants did not actually generate code and move the files to the Raspberry Pi boards themselves. The MathWorks GHC team took care of this step ahead of the workshop so participants could focus on the theory. The workshop leaders walked participants through the script used to generate C++ code for deployment.% Generate code from face detector application
cfg = coder.config('lib');
cfg.TargetLang = 'C++';
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
dlcfg.ArmComputeVersion = '19.02';
cfg.DeepLearningConfig = dlcfg;
cfg.GenCodeOnly = true;
hw = coder.hardware('Raspberry Pi');
cfg.Hardware = hw;
codegen -config cfg detectAge -args ones(416,416,3,'uint8') -d detectAgeCode -report
In addition to learning about code generation, participants learned about techniques used to reduce the size of a deep learning network, including quantization, network optimization, and code generation.
Face and Age Detection on the Raspberry Pi
Participants used a VNC viewer and wired Ethernet connection to connect their own laptops to a Raspberry Pi board the workshop team had set up prior to the session. To start the exercise, they ran the deployed face and age detected algorithm on the same image of the GHC18 workshop team. Then, participants had a lot of fun transferring selfies to the Raspberry Pi for face and age detection in their own images.After the Celebration
The MathWorks team flew home to Natick, taking all the positive energy participants brought to the sessions and many lessons learned about how to produce a successful hardware workshop. We are grateful to have had the opportunity to share the workshop with such a talented and diverse group of women. Upon arriving back at MathWorks headquarters, the MathWorks GHC team got right to work, hand-writing over 150 thank you cards for people outside of the team who contributed valuable time, expertise, and ideas to the content presented. Many of these cards went to people who helped specifically with the Edge AI with Raspberry Pi workshop. Once again, I'd like to thank the many colleagues who volunteered their time to make the workshop a success!Beyond GHC
For the MathWorks GHC team, the work for these workshops is far from over after we leave the conference to head back to Natick. We want to share the learning opportunities and fun with as many people as possible. As an example, check out this blog post about how the GHC18 Hands on with Deep Learning and IoT workshop was shared with Science Day participants at the University of Louisiana Lafayette. If you are interested in delivering the Edge AI with Raspberry Pi workshop at your institution, reach out to Louvere Walker-Hannon at lwalker@mathworks.com. We are already supporting a group who will present the workshop at The Ohio State University. To see more of the fun from MathWorks at GHC19, check out this Twitter moment. To get started with deep learning, take the free Deep Learning Onramp. Follow the #shelovesmatlab hashtag to see the work of awesome women scientists and engineers!- 类别:
- Deep Learning
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。