edit

Getting Started with alwaysAI on NVIDIA® Jetson Devices

alwaysAI is an essential Computer Vision development platform for creating and deploying machine learning applications on Edge devices such as NVIDIA® Jetson devices. Developing and deploying these applications is simply too complex and time-consuming, requiring deep knowledge of a huge array of computer vision technologies and techniques that are more relevant and accessible to specialists than everyday developers. alwaysAI removes these barriers and makes creating computer vision apps easy, fast and effective.

Hardware supported

alwaysAI is supported by the following hardware:

  • Official Development Kits by NVIDIA:

    • NVIDIA® Jetson Nano Developer Kit
    • NVIDIA® Jetson Xavier NX Developer Kit
    • NVIDIA® Jetson AGX Xavier Developer Kit
    • NVIDIA® Jetson TX2 Developer Kit
  • Official SoMs by NVIDIA:

    • NVIDIA® Jetson Nano module
    • NVIDIA® Jetson Xavier NX module
    • NVIDIA® Jetson TX2 NX module
    • NVIDIA® Jetson TX2 module
    • NVIDIA® Jetson AGX Xavier module
  • Carrier Boards by Seeed:

    • Jetson Mate
    • Jetson SUB Mini PC
    • Jetson Xavier AGX H01 Kit
    • A203 Carrier Board
    • A203 (Version 2) Carrier Board
    • A205 Carrier Board
    • A206 Carrier Board

Prerequisites

  • Any of the above Jetson devices running JetPack 4.6 with all SDK components installed (check this wiki for a reference on installation)
  • Host PC with Windows, Linux or Mac
  • USB webcam or MIPI CSI camera supported by your Jetson device

Getting started

Deploying your first computer vision project only takes a couple of minutes! By the end of this wiki, you will be able to detect objects on a live video feed from a camera connected to a Jetson device and also on a pre-loaded video file.

  1. Setup environment for development computer
  2. Setup environment for Jetson device
  3. Sign up for alwaysAI account
  4. Create a project using alwaysAI dashboard
  5. Deploy your project on the Jetson device using development computer
  6. Object detection on live video feed from camera
  7. Object detection on pre-loaded video file

Setup environment for development computer

Now you need to setup the development environment. Here you can use either a windows, Linux or Mac computer.

!!!Note: In this guide, we will use a windows development computer. However, if you want to setup Mac or Linux as your developmenmt PC, please visit here to learn more.

  • Step 1. Download and install alwaysAI desktop application and command-line interface by clicking here

  • Step 2. After the installation is finished, open a command-line interface and type the following

aai -v

If you see a version number printed, you have successfully installed alwaysAI CLI. The version number at the time of writing this wiki is 1.4.3

  • Step 3. Check whether OpenSSH is already installed in your OS. You need OpenSSH on the development machine to connect to your edge device and deploy the machine learning projects.
ssh -V

If you see a version number printed, you have OpenSSH already installed. For example OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2. As of late 2018, Windows 10 supports OpenSSH out of the box. Check out this article on the Microsoft docs site for more information on installing OpenSSH on Windows

Setup environment for Jetson device

Next you need to setup the environment on the edge device (Jetson device in this case).

Step 1. Open a terminal window on the Jetson device and install Node.js

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs

!!!Note: Here we install Node.js 16 along with npm 8 which are the latest releases at the time of writing this wiki. alwaysAI CLI requires Node.js v8.0.0 or greater and npm v5.0.0 or greater, so it is better to install the latest versions of both Node.js and npm

Step 2. Execute the following to check if Node.js is properly installed

node -v

If you see a version number printed, you have successfully installed Node.js. The version number at the time of writing this wiki is v16.14.0

Step 3. Execute the following to check if npm is properly installed

npm -v

If you see a version number printed, you have successfully installed npm. The version number at the time of writing this wiki is 8.3.1

Step 3. Proceed to installing alwaysAI CLI

sudo npm install --global alwaysai

Step 4. Check if alwaysAI is properly installed

aai -v

If you see a version number printed, you have successfully installed alwaysAI CLI. The version number at the time of writing this wiki is 1.4.3

  • Step 5. Check whether OpenSSH is already installed
ssh -V

If you see a version number printed, you have OpenSSH already installed. For example OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017. You do not need to install this manually because, Jetpack already comes with OpenSSH pre-installed.

Step 6. When running our machine learning project on the Jetson device, we need the edgeIQ runtime which is available as a docker image. You do not need to install Docker because it already comes pre-installed with JetPack. However you need to add the "docker" group to your user so that you do not need root priviledges (sudo) to access Docker

sudo usermod -aG docker $USER

Step 7. To apply the new group membership, log out of the Jetson device and back in, or type the following

su - $USER

Step 8. Test your docker installation without sudo

docker run hello-world

Sign up for alwaysAI account

  • Step 1. Visit this page to sign up for an alwaysAI account

  • Step 2. Fill out the form and click Sign Up for Free to finish the sign up process

Create a project using alwaysAI dashboard

After completing the environment setups on development machine and Jetson device, signing up for an alwaysAI account, we can start to create a new object detection project using alwaysAI dashboard.

Step 1. Visit the alwaysAI dashboard and create a new project by clicking New Project button

Step 2. Choose Object Detection as a starting template, enter a project name and click Create Project

Step 3. Click Click Here To View Your Project to enter your newly created project

Now you will see information about the newly created project such as the model used and other useful details

Deploy your project on the Jetson device using development computer

Now we will deploy the project that we created before on to the Jetson device using the development computer via SSH

Step 1. On the development machine, create a new folder, open a command-line interface inside the new folder and type the following

aai app configure

!!!Note: You wil be prompted to enter the username and password of alwaysAI account when you run the above command for the very first time

Step 2. Select the project that you created before on alwaysAI dashboard

Step 3. Choose Remote device as destination

Step 4. Press Y to create the private key file

Step 5. Click Add a new device to add your Jetson device as a remote device

Step 6. Choose device mode as Development

Step 7. Enter a device name

Step 8. Enter the username of Jetson device along with hostname/IP address as follows

lakshanthad@192.168.2.156

!!!Note: Here username of Jetson device is lakshanthad and IP address is 192.168.2.156

Step 9. Enter the password of Jetson device when prompted

Step 10. When it asks for the location to run the app, leave the default location and press ENTER. Here the default location is set as alwaysai/test. This is the project directory inside the Jetson device

Now we have successfully initialized the project on the Jetson device using the development computer via SSH

Step 11. Type the following to install the app

aai app install

You will see the following output if it is successfully installed

!!!Note: If you encounter errors at this step, you can first try to redeploy using the aai app install --clean method. Double check that the jetpack version is the requested version 4.6.x. This can be checked by typing the command sudo apt-cache show nvidia-jetpack. If the version number is correct, make sure that you completed the Jetson system installation along with the Jetson SDK components. This will help you solve most issues.

Object detection on live video feed from camera

Now we will run the object detection on a live video feed from a USB camera connected to the Jetson device. You can also use MIPI CSI cameras which are supported by the Jetson device that you are using

Step 1. Connect USB camera/ MIPI CSI camera to the Jetson device

Step 2. Run the following

aai app start

Now you will see the following output on the command-line

As you can see, we are using the mobilenet_ssd model and this model is able to identify the following: background, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa, train, tv monitor

Step 3. Open a web browser and type the IP address of the Jetson device followed by port 5000 to open the video stream

192.168.2.156:5000

As you can see, the human and the dogs on the live video stream are being detected in real-time and the confidence percentage for each label is shown on the interface.

Object detection on pre-loaded video file

Here we will run the object detection on a pre-loaded video file.

Step 1. Place the video file inside the alwaysAI project directory of Jetson device. According to our example, it is /home/{username}/alwaysai/test

Step 2. On the development computer, open app.py file inside the test folder that we created before and replace this section of the code

with edgeiq.WebcamVideoStream(cam=0) as video_stream, \
                edgeiq.Streamer() as streamer:

with this one

with edgeiq.FileVideoStream(
            'file name goes here', play_realtime=True) as video_stream, \
                edgeiq.Streamer() as streamer:

And then replace file name goes here with the name of the video file and the file extension. Make sure the filename should be inside single inverted commas.

Step 3. Intall the app again

aai app install

Step 4. Finally run the app

aai app start

Here you will see the same output on the command line as before, and once you open a web browser with the same address as mentioned before, you will see object detection being performed on the pre-loaded video, giving similar output as before.

Resources

Tech Support

Please submit any technical issue into our forum.