FPGA AI Suite: SoC Design Example User Guide

ID 768979
Date 3/29/2024
Public
Document Table of Contents

8.4.2. The image_streaming_app Application

The image_streaming_app application loads images from the SD card, programs the layout transform IP, and then transfers the buffers via a streaming mSGDMA interface to the device. The buffers are sent at regular intervals at a frequency set by one of the command line options. Buffers are continually sent until the program is stopped with Ctrl+C.

The image_streaming_app application works only with .bmp files with dimensions of 224x224 pixels. The .bmp files can be either 24 or 32 bits per pixel format. If they are 24 bits, the buffers are padded to make them 32 bits per pixel. This format is expected by the input of the layout transform IP .

The command usage from the -help command option is as follows:
root@arria10-ea80b8d770e7:~/app# ./image_streaming_app --help
Usage:
 image_streaming_app [Options]

Options:
-images_folder=folder     Location of bitmap files. Defaults to working folder.
-image=path               Location of a single bitmap file for single inference.
-send=n                   Number of images to stream. Default is 1 if -image is set, otherwise infinite.
-rate=n                   Rate to stream images, in Hz. n is an integer. Default is 30.
-width=n                  Image width in pixels, default = 224
-height=n                 Image height in pixels, default = 224
-c_vector=n               C vector size, default = 32
-blue_variance=n          Blue variance, default = 1.0
-green_variance=n         Green variance, default = 1.0
-red_variance=n           Red variance, default = 1.0
-blue_shift=n             Blue shift, default = -103.94
-green_shift=n            Green shift, default -116.78
-red_shift=n              Red shift, default = -123.68

The distribution includes a shell script utility called run_image_stream.sh that calls the image_streaming_app command with a rate of 50 Hz and default layout transform settings.

Once both applications are running, the streaming_inference_app application outputs the results to the terminal and a results.txt file.

Example output from the streaming_inference_app application is as follows:
root@arria10-ea80b8d770e7:~/app# ./run_inference_stream.sh
Runtime arch check is enabled. Check started...
Runtime arch check passed.
Runtime build version check is enabled. Check started...
Runtime build version check passed.
Ready to start image input stream.
1 - coffee mug, score = 93.9453
2 - acoustic guitar, score = 38.6963
3 - desktop computer, score = 43.9209
4 - guacamole, score = 99.9512
5 - red wine, score = 55.1758
6 - stopwatch, score = 38.8428
7 - jigsaw puzzle, score = 100
8 - table lamp, score = 76.7578
9 - wool, score = 19.5801
10 - coffee mug, score = 93.9453
11 - acoustic guitar, score = 38.6963
12 - desktop computer, score = 43.9209
13 - guacamole, score = 99.9512
14 - red wine, score = 55.1758
15 - stopwatch, score = 38.8428
16 - jigsaw puzzle, score = 100
17 - table lamp, score = 76.7578
18 - wool, score = 19.5801

Ctrl+C
The resulting results.txt file from the example is as follows:
root@arria10-ea80b8d770e7:~/app# cat results.txt
Result: image[1]
1. coffee mug, score = 93.9
2. cup, score = 4.7
3. pitcher, score = 0.3
4. teapot, score = 0.2
5. whiskey jug, score = 0.2

Result: image[2]
1. acoustic guitar, score = 38.7
2. electric guitar, score = 38.7
3. banjo, score = 8.6
4. accordion, score = 1.9
5. sleeping bag, score = 1.2

Result: image[3]
1. desktop computer, score = 43.9
2. computer keyboard, score = 16.2
3. monitor, score = 9.8
4. desk, score = 9.8
5. notebook, score = 7.6

Result: image[4]
1. guacamole, score = 100.0
2. head cabbage, score = 0.0
3. motor scooter, score = 0.0
4. missile, score = 0.0
5. mosquito net, score = 0.0