Building a battery-operated smart camera in five steps using a multi-core microcontroller
Power consumption is the major concern when designing a battery-operated camera system that interprets images on an edge sensor. GREENWAVES' GAP application processors enable new types of devices that combine ultra-low power consumption with sophisticated signal processing and neural network algorithms.
In this post, we demonstrate how to train and deploy a deep learning model for image recognition on GAP8—the first generation of ultra-low power IoT application processors. Thanks to the power-optimized MCU-class architecture tailored for intensive AI workloads, GAP8 is the perfect solution when coupled with low-power cameras.
A GAP8-based smart camera that leverages Convolutional Neural Networks MobilenetV2 can process image data while consuming less than 37.5 mW/FPS.
In this post, you will learn the necessary design steps to build a GAP8-based smart camera system from data to prototype in a few hours. After training and converting a model using the TensorFlow toolkit, the GAPflow toolset is exploited to bring trained models on the GAP8 chip.
You can also find more information in our NN Menu—GreenWaves’ repository, which contains common mobile and edge NN architecture examples, NN sample applications, and full flagged reference designs. Our tools map a TFLlite model (quantized or unquantized) onto Gap.
Overview
The design process consists of the following five steps:
1. Data Collection to feed the training process of the Convolutional Neural Network
2. Model Training
3. Graph Conversion to a format that can be fed to the GAPflow toolset
4. GAPflow to generate a GAP-optimized C code for inference
5. Deployment of the generated code on the board
Each step will be detailed based on the vehicle spotting use case.
Requirements
The DL model design relies on the open-source Tensorflow Slim (TF1.x) to train and convert the model (Steps 1–3). GAPflow, which is part of the GAP SDK, brings the DL model to the board (Steps 4–5).
Step 1: Build the Dataset
Training a neural network for vehicle spotting requires a large training dataset, including thousands of labeled image samples. Fortunately, a large number of samples can be freely downloaded from OpenImages by distilling the COCO dataset. Accordingly, TFSlim includes the script to build a custom dataset with the intended classes (foreground_class_of_interest):
python3 slim/download_and_convert.py --dataset_name=visualwakewords --dataset_dir=visualwakewords_vehicle --foreground_class_of_interest='bicycle','car','motorcycle','airplane','bus','train','truck','boat' --small_object_area_threshold=0.05 --download --coco_dir=/path/to/coco_dataset
The small_object_area_threshold specifies the minimum area (in percentage) of a target object to label a COCO image as “Object Spotted.”
Step 2: Train the Deep Learning Model (with Quantization)
The TFSlim package includes the train_image_classifier script to train custom image classifiers on a selected dataset (dataset_dir). The model architecture can be selected from a set of available models. In our project, we choose a MobileNetV2 model and we train it on 224×224 greyscale image crops (use_grayscale option) – training images are converted to greyscale before feeding the model.:
python3 train_image_classifier.py --train_dir='vww_vehicle_train_grayscale' --dataset_name='visualwakewords' --dataset_split_name=train --dataset_dir='./visualwakewords_vehicle/' --log_every_n_steps=100 --model_name='mobilenet_v2' --checkpoint_path='./vww_vehicle_train_grayscale/' --max_number_of_steps=100000 --num_clones=1 --quantize_delay=90000 --use_grayscale
A quantization aware-training process is applied to quantize the model to 8-bit. The quantization starts after 90,000 training steps (quantize_delay). A symmetric quantization rule, compliant with the GAP8 inference library, is imposed by setting contrib_quantize.experimental_create_training_graph_(symmetric=True)) (line 538 of the training script).
The accuracy of the trained model is assessed by evaluating it on the validation set:
python3 eval_image_classifier.py --checkpoint_path='vww_train_vehicle_grayscale/' --eval_dir='vww_eval_vehicle_grayscale/' --dataset_split_name=val --dataset_dir='visualwakewords_vehicle/' --dataset_name='visualwakewords' --model_name='mobilenet_v2' --quantize --use_grayscale
In case of vehicle spotting, a MobilenetV2 reaches 87% of classification accuracy with grayscale images and quantization, a percentage only 2% lower than that of the accuracy a quantized MobilenetV2_0.35 model reaches when trained on RGB images.
Step 3: Export and Convert the Quantized Inference Model to TFLite format
The trained model is exported and frozen before the conversion to TFlite format, again leveraging TFSlim scripts:
python3 slim/export_inference_graph.py --model_name=mobilenet_v2 --image_size=224 --output_file=./mobilenet_v2_224_grayscale.pb --quantize --use_grayscalefreeze_graph --input_graph=./mobilenet_v2_224_grayscale.pb --output_graph=./frozen_mbv2_224_grayscale.pb --input_checkpoint=./vww_train_vehicle_grayscale/model.ckpt-100000 --input_binary=true --output_node_names=MobilenetV2/Predictions/Reshape_1tflite_converter --graph_def=./frozen_mbv2_224_grayscale.pb --output_file=mbv2_grayscale.tflite --input_arrays=input --output_arrays=MobilenetV2/Predictions/Reshape_1 --inference_type=QUANTIZED_UINT8 --std_dev_val=128 --mean_val=128
Step 4: GAPflow
The GAPflow (please see figure below) is a toolset that converts a TFlite model into GAP-optimized C code to run inference on image sensor data. The script-based flow can be found here. Specifically, NNtool is invoked to convert the tflite file into an intermediate representation format—the AT model. This latter feeds the Autotiler tools, which are in charge of generating the final C code.
To perform these steps, the Makefile is configured to run the GAPflow operations.
make clean all [RGB=1]
RGB=1 needs to be configured in case an RGB sensor is available. Fast customization can be applied by changing the Makefile and the common.mk variables, which specify the location of the
Step 5: Get the Board and Run the Model
The generated inference code functions are called within the main application code to run inference on sensor data. You only need to connect the image sensor to the Gapuino board, and you can test your first smart camera module by running:
make run [RGB=1]
Conclusion
The GAP toolset enables AI at the very edge with seamless integration with major deep learning frameworks and provides a power-optimized solution that AI experts or embedded systems designers can use to enable new generation products.
- |
- +1 赞 0
- 收藏
- 评论 0
本文由出山转载自GREENWAVES Official Website,原文标题为:Building a battery-operated smart camera in five steps using a multi-core microcontroller,本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。
相关推荐
Automated design intelligence with GAPflow
Our first product GAP8, in production since the beginning of 2020, is the leading off-the-shelf ultra-low power IoT Application Processor that combines ultra-low energy consumption, low-cost and high-computational power for compute-intensive tasks but still preserving the form-factor, system cost, energy efficiency and flexibility of a typical microcontroller.
设计经验 发布时间 : 2024-08-20
Visual Wakewords on GREENWAVES GAP8
In the latest GAP SDK, released on the 7th February 2020, we have included a GAPflow example that converts the winner of the Google Visual Wake Words challenge to a working model on GAP8.
设计经验 发布时间 : 2024-08-13
GreenWaves Technologies Partners with Open-Silicon to develop Industry’s First IoT Processor Based on PULP and RISC-V
Open-Silicon, a system-optimized ASIC solution provider, today announced it was selected by GreenWaves Technologies to develop GAP8, the industry’s first IoT processor. GAP8 is built on the open source Parallel Ultra Low Power (PULP) and RISC-V ISA projects. Open-Silicon is providing GreenWaves Technologies with the complete RTL-to-physical design custom SoC implementation that is required to transform this smart IoT concept into working silicon in volume production.
产品 发布时间 : 2024-08-20
GreenWaves Presented at Edge AI Summit in 18-20 November 2020
Greenwaves Technologies was proud to be a sponsor of the Edge AI virtual summit in 18-20 November 2020. Greenwaves presented GAP IoT application processors based on RISC-V architecture and will share knowledge and expertise in Edge Computing and Artificial intelligence.
原厂动态 发布时间 : 2024-08-09
A 64mW DNN-based Visual Navigation Engine for Autonomous Nano-Drones
Really interesting paper by Daniele Palossi on using GAP8 to autonomously navigate a microdrone. This is a great example of porting a significant CNN to GAP8. Eric Flamand, GreenWave’s CTO assisted with the CNN model creation and use of the AutoTiler CNN generators.
应用方案 发布时间 : 2024-09-30
GreenWaves Technologies Licenses Intrinsic ID Hardware Root of Trust for RISC-V AI Application Processor
GreenWaves’ pioneering RISC-V-based IoT application processors enable the cost-effective development, deployment and autonomous operation of intelligent, battery-operated sensing devices that capture, analyze, classify and act on the fusion of rich data sources such as images, sounds or vibrations at the very edge of the network.
产品 发布时间 : 2024-08-20
New GAP8 SDK V2.1 Was Released from GreenWaves Technologies
New GAP8 SDK release from GreenWaves Technologies. This article will show the headline changes in this SDK.
产品 发布时间 : 2024-08-22
GAP8 Performance Versus ARM M7 on Embedded CNNs
ARM recently published a new CMSIS library for embedded convolutional neural networks (CNNs) CMSIS-NN. Firstly, it was great to see ARM supporting the market that GreenWaves and GAP8 are focused on. We particularly liked their statement that: “Neural Networks are becoming increasingly popular in always-on IoT edge devices performing data analytics right at the source, reducing latency as well as energy consumption for data communication.”
产品 发布时间 : 2024-09-10
GreenWaves Technologies Won the Silver Golden Mousetrap Award 2019
Grenoble, France, Feb 5, 2019 – GreenWaves Technologies, a fabless semiconductor startup designing disruptive ultra-low-power embedded solutions for image, sound, and vibration artificial intelligence processing in sensing devices, announced today that it has been selected as a winner of a silver Golden Mousetrap award 2019.
原厂动态 发布时间 : 2024-08-13
Lynred and GreenWaves collaborate on New Occupancy Management Reference Platform for People Counting Sensor
GreenWaves and Lynred have collaborated on an open-source workspace management platform that allows quick deployment of sensors collecting accurate occupancy data. This platform combines Lynred‘s low-power IR sensors with GreenWaves‘ GAP8 processor to create battery-operated people counting devices, released under open source licenses. The platform ensures occupant anonymity using infrared technology and will be demonstrated at Embedded World in Nuremburg, Germany.
产品 发布时间 : 2024-09-07
GreenWaves Technologies Announced Availability of GAP8 Software Development Kit and GAPuino Development Board
GreenWaves’ pioneering GAP8 IoT Application Processor enables high-performing evaluation board and development kit.Grenoble, France and Santa Clara, Calif., May 22, 2018 – GreenWaves Technologies, a fabless semiconductor startup designing disruptive ultra-low power embedded solutions for image, sound and vibration AI processing in sensing devices, today announced the availability of its GAP8 Software Development Kit (SDK) and GAPuino Development Board. The GAPuino Boards are available for purchase here and the GAP8 SDK can be downloaded via GitHub.
产品 发布时间 : 2024-08-20
GreenWaves Technologies Announces 7M€ Series A Funding with Huami, Soitec and other investors
Funds will finance the sales ramp of GreenWaves’ first product, GAP8,and the development of the GREENWAVES company’s next generation product.
原厂动态 发布时间 : 2024-08-31
GAPMod 3.x GAP8 Centric Core Module with QSPI memories HARDWARE OVERVIEW
型号- GAPMOD3.0,GAP8,GAPMOD,GAPMOD 3.X
GAPPoc : A Family of GAP8-centric Proof Of Concept boards for Edge AI
Our GAP8 application processor chip is great at analyzing and understanding data from IoT sensors, from the simplest to the most complex, in a very tight power envelope – from a few tens of milliwatt in active mode down to a few microwatts in sleep mode.
产品 发布时间 : 2024-08-14
服务
支持 3Hz ~ 26.5GHz射频信号中心频率测试;9kHz ~ 3GHz频率范围内Wi-SUN、lora、zigbee、ble和Sub-G 灵敏度测量与测试,天线阻抗测量与匹配电路调试服务。支持到场/视频直播测试,资深专家全程指导。
实验室地址: 深圳/苏州 提交需求>
拥有中等规模的SMT、DIP以及成品组装产线;支持PCBA及成品OEM/ODM代工组装制造;在嵌入式系统、物联网系统等具备专业性量产制造的项目组织和服务能力。
提交需求>
登录 | 立即注册
提交评论