Developer stories to your inbox.

Subscribe to the Developer Digest, a monthly dose of all things code.

You may unsubscribe at any time using the unsubscribe link in the digest email. See our privacy policy for more information.

alwaysAI Ad

Deploying with Balena

By Jason Koo May 05, 2020

This short guide will show you how to combine alwaysAI and Balena to easily deploy a computer vision application to multiple devices with a single command.

Balena is an easy to use, yet powerful cloud based fleet management tool for enabling, maintaining and managing applications on a variety of device architectures. This is a perfect fit with alwaysAI’s capability of running computer vision applications on nearly any single board computer or edge device.

REQUIREMENTS

To get started, you’ll need the following:

 

ALWAYSAI APP

The following steps can be used with any alwaysAI app. If you don’t have one ready yet, this sample app can be used to follow along with.

RELATED: Learn how to create and run an object detector starter app in minutes 

STEPS

  1. Create a Balena App with Balena’s dashboard. The application name you choose here is what you’ll use instead of the <balena_app_name> placeholders in the following steps.
  2.  Install the appropriate Balena OS image onto your target device(s)
  3.  **Downloading models for deployment by running ALWAYSAI_HOME=$(pwd) aai app install
  4.  *Create a "Dockerfile.template" file with the contents:
    • FROM alwaysai/edgeiq:0.13.0
    • WORKDIR /app
    • COPY . ./
    • CMD ["python3","app.py"]
  5. *Push upwith Balena’s CLI command to your Balena app: balena push <balena_app_name>`

*Steps 3-5 can be executed via this convenience gist. Just download and run it, or invoke it remotely with the following curl command:

curl https://gist.githubusercontent.com/jalakoo/0492d85c0260e17e455a2caac6e3e1ca/raw/82b210bf93eeb083efaa5c2f676f2ec8a7e5d3b9/deploy_to_balena.sh | sh -s <balena_app_name>

**Step 3 on a linux system will fail if ALWAYSAI_HOME is not set prior to running this command.

If successful, you should see something like the following in your console:

And from your Balena dashboard you should see something similar to:

If you have a computer on the same network as the device, you can connect to the debug streamer by entering the device IP address and port 5000 in any browser, ie 192.168.2.3:5000, and see something like:

That’s it. So long as you use Balena to add additional devices, code from an alwaysAI application deployed this way will automatically update and run on all the devices added. If you’re not already an alwaysAI user, register today at: https://www.alwaysai.co

Get Started Now
We are providing professional developers with a simple and easy-to-use platform to build and deploy computer vision applications on edge devices.
Get Started Now
By Jason Koo May 05, 2020