Skip to main content

Deep learning gateway on Raspberry Pi and other edge devices.

Project description

BerryNet Logo

Deep Learning Gateway on Raspberry Pi And Other Edge Devices

Docker Image CI

Supporting BerryNet

Introduction

This project turns edge devices such as Raspberry Pi into an intelligent gateway with deep learning running on it. No internet connection is required, everything is done locally on the edge device itself. Further, multiple edge devices can create a distributed AIoT network.

At DT42, we believe that bringing deep learning to edge devices is the trend towards the future. It not only saves costs of data transmission and storage but also makes devices able to respond according to the events shown in the images or videos without connecting to the cloud.

Figure 1

Figure 1: BerryNet architecture

Figure 1 shows the software architecture of the project, we use Node.js/Python, MQTT and an AI engine to analyze images or video frames with deep learning. So far, there are two default types of AI engines, the classification engine (with Inception v3 [1] model) and the object detection engine (with TinyYOLO [2] model or MobileNet SSD [3] model). Figure 2 shows the differences between classification and object detection.

Figure 2

Figure 2: Classification vs detection

One of the application of this intelligent gateway is to use the camera to monitor the place you care about. For example, Figure 3 shows the analyzed results from the camera hosted in the DT42 office. The frames were captured by the IP camera and they were submitted into the AI engine. The output from the AI engine will be shown in the dashboard. We are working on the Email and IM notification so you can get a notification when there is a dog coming into the meeting area with the next release.

Figure 3

Figure 3: Object detection result example

To bring easy and flexible edge AI experience to user, we keep expending support of the AI engines and the reference HWs.

Figure 4

Figure 4: Reference hardwares

Installation

You can install BerryNet by using pre-built image or from source. Please refer to the Wiki page for the details.

We are pushing BerryNet into Debian repository, so you will be able to install by only typing one command in the future.

Here is the quick steps to install from source:

$ git clone https://github.com/DT42/BerryNet.git
$ cd BerryNet
$ ./configure

Start and Stop BerryNet

BerryNet performs an AIoT application by connecting independent components together. Component types include but not limited to AI engine, I/O processor, data processor (algorithm), or data collector.

We recommend to manage BerryNet componetns by supervisor, but you can also run BerryNet components manually. You can manage BerryNet via supervisorctl:

# Check status of BerryNet components
$ sudo supervisorctl status all

# Stop Camera client
$ sudo supervisorctl stop camera

# Restart all components
$ sudo supervisorctl restart all

# Show last stderr logs of camera client
$ sudo supervisorctl tail camera stderr

For more possibilities of supervisorctl, please refer to the official tutorial.

The default application has three components:

  • Camera client to provide input images
  • Object detection engine to find type and position of the detected objects in an image
  • Dashboard to display the detection results

You will learn how to configure or change the components in the Configuration section.

Dashboard: Freeboard

Open Freeboard on RPi (with touch screen)

Freeboard is a web-based dashboard. Here are the steps to show the detection result iamge and text on Freeboard:

  • 1: Enter http://127.0.0.1:8080 in browser's URL bar, and press enter
  • 2: Download the Freeboard configuration for default application, dashboard-tflitedetector.json
  • 2: Click LOAD FREEBOARD, and select the newly downloaded dashboard-tflitedetector.json
  • 3: Wait for seconds, you should see the inference result image and text on Freeboard

Open Freeboard on another computer

Assuming that you have two devices:

  • Device A with IP 192.168.1.42, BerryNet default application runs on it
  • Device B with IP 192.168.1.43, you want to open Freeboard and see the detection result on it

Here are the steps:

  • 1: Enter http://192.168.1.42:8080 in browser's URL bar, and press enter
  • 2: Download the Freeboard configuration for default application, dashboard-tflitedetector.json
  • 3: Replace all the localhost to 192.168.1.42 in dashboard-tflitedetector.json
  • 2: Click LOAD FREEBOARD, and select the newly downloaded dashboard-tflitedetector.json
  • 3: Wait for seconds, you should see the inference result image and text on Freeboard

For more details about dashboard configuration (e.g. how to add widgets), please refer to Freeboard project.

Enable Data Collector

You might want to store the snapshot and inference results for data analysis.

To run BerryNet data collector manually, you can run the command below:

$ bn_data_collector --topic-config <topic-config-filepath> --data-dirpath <result-dirpath>

The topic config indicates what MQTT topic the data collector will listen, and what handler will be triggered. Here is a topic config exmaple:

{
    "berrynet/engine/tflitedetector/result": "self.update"
}

The inference result image and text will be saved into the indicated result directory.

Configuration

The default supervisor config is at /etc/supervisor/conf.d/berrynet-tflite.conf. To write your own supervisor config, you can refer to here for more example supervisor configs of BerryNet

Camera Client

BerryNet camera client can run in two modes: stream or file. In stream mode, local camera (e.g. USB camera and RPi camera) and IP camera can be supported, and input frame rate (FPS) can be changed on demand (default is 1). In file mode, user can indicate filepath as input source.

To run camera client in stream mode:

$ bn_camera --fps 5

To run camera client in file mode:

$ bn_camera --mode file --filepath <image-filepath>

Use Your Data To Train

The original instruction of retraining YOLOv2 model see github repository of darknet

In the current of BerryNet, TinyYolo is used instead of YOLOv2. The major differences are:

  1. Create file yolo-obj.cfg with the same content as in tiny-yolo.cfg
  2. Download pre-trained weights of darknet reference model, darknet.weights.12, for the convolutional layers (6.1MB) https://drive.google.com/drive/folders/0B-oZJEwmkAObMzAtc2QzZDhyVGM?usp=sharing

The rest parts are the same as retraining YOLO.

If you use LabelMe to annotate data, utils/xmlTotxt.py can help convert the xml format to the text format that darknet uses.

Discussion

Please refer to the Slack, Telegram Group or Google Group for questions, suggestions, or any idea discussion.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

berrynet-3.10.1.tar.gz (48.5 kB view details)

Uploaded Source

Built Distribution

berrynet-3.10.1-py3-none-any.whl (97.5 kB view details)

Uploaded Python 3

File details

Details for the file berrynet-3.10.1.tar.gz.

File metadata

  • Download URL: berrynet-3.10.1.tar.gz
  • Upload date:
  • Size: 48.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for berrynet-3.10.1.tar.gz
Algorithm Hash digest
SHA256 bb4cfabecd3378ae26346b17bcac4858d3ff5315506a512829da85db42dfac61
MD5 8a2929e4f89f6c386cb90fd6aad2ea5b
BLAKE2b-256 8a7ed9b7889c52549b21ca9b9f3329e2417f9527b72dcd7e30e6ca5c5cc56e3f

See more details on using hashes here.

File details

Details for the file berrynet-3.10.1-py3-none-any.whl.

File metadata

  • Download URL: berrynet-3.10.1-py3-none-any.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for berrynet-3.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5c286be7f5f12584bd93e0cacf6ee7a79fe72e370b899d1b6838d416d366f58
MD5 d3f4ccbc4561529a73b7a442348096d1
BLAKE2b-256 cc6571995017598d45e5e014d1ce270fd12de579d51809d0c8fe3060e3e6a1d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page