Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Edge Data Processing With Jetson Nano

DZone 's Guide to

Edge Data Processing With Jetson Nano

Learn more about edge data processing with Jetson Nano.

· IoT Zone ·
Free Resource

In my other NVidia Jetson Nano articles, we did basic set-up and installed the necessary libraries (though there is a now a Jetpack 4.2.1 update that I need to install and see if we get performance enhancements). We now updated to the latest jetson-inference code as it updated and included excellent Python examples. We now have a platform to work with that has everything we need for IoT — a fast CPU, fast GPU, enough RAM, great software, and the ability to stream data and images off of it with decent performance. So, let's get to building an IoT workflow with AI, device status, and images. We are using Cloudera's Edge Flow Manager to configure, build, deploy, monitor, and manage our IoT flows. We can push to all the Jetson Nano's we have and not have to worry about hand installing on hundreds of devices. It's very easy, as shown below.

Configuring Executing Image Capture and Jetson Nano Classify Python Script

Configuring Tailing JSON Log

Configuring Acquiring Images from File Directory

Configuring the Remote Connection to NiFi

Example CEM Events

Simple NiFi Flow to Receive Remote Events

Apache NiFi Server receives from annotated images as well as JSON packets.

JSON Data Packet Example

{"uuid": "nano_uuid_kwo_20190719182103", "ipaddress": "192.168.1.254", "top1pct": 32.6171875, "top1": "desktop computer", "cputemp": "32.5", "gputemp": "31.5", "gputempf": "89", "cputempf": "90", "runtime": "5", "host": "jetsonnano", "filename": "/opt/demo/images/image_bei_20190719182103.jpg", "imageinput": "/opt/demo/images/2019-07-19_1421.jpg", "host_name": "jetsonnano", "macaddress": "de:07:5a:27:1e:7f", "end": "1563560468.7867181", "te": "4.806252717971802", "systemtime": "07/19/2019 14:21:08", "cpu": 55.8, "diskusage": "5225.1 MB", "memory": 57.5, "id": "20190719182103_fcaa94d4-7629-423a-b76e-714168e64677"}


Notes

It was very easy to set-up a simple flow to execute out deep learning classification and data acquisition with Apache NiFi, MiNiFi, and Cloudera EFM. We can now do something with the data, like push it to the cloud.

Source:

https://github.com/tspannhw/minifi-jetson-nano

import jetson.inference
import jetson.utils

# pass in command line arguments
net = jetson.inference.imageNet("googlenet", argv)

# we load an image capture with fswebcam capture
img, width, height = jetson.utils.loadImageRGBA("imagename.jpg")

# see https://github.com/tspannhw/minifi-jetson-nano/blob/master/demo.py
# https://github.com/tspannhw/minifi-jetson-nano/blob/master/rundemo.sh

# classify the image with a determine width and height
class_idx, confidence = net.Classify(img, width, height)

# find the object description text
class_desc = net.GetClassDesc(class_idx)

# Mark up the image with description
font = jetson.utils.cudaFont(size=jetson.utils.adaptFontSize(width))
font.OverlayText(img, width, height, "{:f}% {:s}".format(confidence * 100, class_desc), 10, 10, font.White, font.Gray40)
jetson.utils.cudaDeviceSynchronize()

# Save the marked up image as a file
jetson.utils.saveImageRGBA(filename, img, width, height)


Deep Learning/IoT

Now, we can start building our deep learning classifications with great speed.

After set-up, we now have an easy interface to running deep learning. As seen in the code above, it is pretty easy to create a simple classification using prebuilt models and webcamers. Using Python 3 and some libraries, we can grab other data like TCP/IP and system information to send as part of a JSON IoT message to a server, like Apache NiFi, to process at scale.

Image title

A recent update to jetson-inference examples have included some great Python examples for the new Python interface: https://github.com/dusty-nv/jetson-inference/blob/master/docs/imagenet-example-python-2.md.

For me, this really elevates the usefulness of the Jetson Nano for IoT with AI. With this solid 4GB device the only slight hold back is having to add Wi-Fi, though a Wi-Fi USB stick is $15 or less. I am in the middle of running my own performance tests against Raspberry Pi 4 with Intel Movidius 2, NVidia Jetson Nano, and Raspberry Pi 3B+ with Google Coral USB. All of them are solid enhancements over basic IoT, but I am seeing a lot of performance enhancements and stability with 4GB of RAM. Now if someone would add a large, fast SSD in a small form factor that could really assist as some of the pre-trained models, libraries, CUDA, Python, development tools, MiNiFi agents, JDK, logs, cache, OS, and more really fills up space quickly and could also slow down performance in IoT situations.

Reference:

Python Docs

Topics:
big data ,deep learning ,apache nifi ,minifi ,python ,jetson-nano ,nvidia ,iot

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}