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.
To get started, you’ll need the following:
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.
- 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.
- Install the appropriate Balena OS image onto your target device(s)
- **Downloading models for deployment by running ALWAYSAI_HOME=$(pwd) aai app install
- *Create a "Dockerfile.template" file with the contents:
- FROM alwaysai/edgeiq:0.13.0
- WORKDIR /app
- COPY . ./
- CMD ["python3","app.py"]
- *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.