|
| 1 | +.. _Webserver-Demo-User-Guide-label: |
| 2 | + |
| 3 | +============================ |
| 4 | +Web server demo - User Guide |
| 5 | +============================ |
| 6 | + |
| 7 | +********* |
| 8 | +Overview |
| 9 | +********* |
| 10 | + |
| 11 | +This document describes the Out of Box Web Server Demo Application, which the Linux |
| 12 | +SDK delivers with the |__SDK_FULL_NAME__| |__PART_FAMILY_NAME__|, applicable to boards |
| 13 | +such as the `BEAGL-BONE-GRN-ECO <https://www.ti.com/tool/BEAGL-BONE-GRN-ECO>`__ and |
| 14 | +`TMDXEVM3358 <https://www.ti.com/tool/TMDXEVM3358>`__. The main purpose of this demo is to |
| 15 | +showcase a glimpse of the ARM analytics AI stack integrated into the filesystem, |
| 16 | +providing an out-of-box experience even users do not connect a display to the board. |
| 17 | + |
| 18 | +The demo showcases a web server running on an AM335x based board, providing a web interface with three key sections: |
| 19 | + |
| 20 | +* **Audio Classification Demo**: Users can connect a USB audio capture device to run real-time audio classification, displaying classification statistics. |
| 21 | +* **Live CPU Performance Metrics**: Provides a real-time CPU usage indicator, historical usage data for the last 5 minutes, and detailed CPU information. |
| 22 | +* **Documentation Links**: Offers convenient access to relevant documentation. |
| 23 | + |
| 24 | +This document provides all necessary equipment requirements and instructions. |
| 25 | + |
| 26 | +********************** |
| 27 | +Hardware Prerequisites |
| 28 | +********************** |
| 29 | + |
| 30 | +- TI AM335x based board (e.g., `BEAGL-BONE-GRN-ECO <https://www.ti.com/tool/BEAGL-BONE-GRN-ECO>`__ and `TMDXEVM3358 <https://www.ti.com/tool/TMDXEVM3358>`__) |
| 31 | + (Note: For the Beaglebone Green Eco, a display is available via an `HDMI cape <https://wiki.seeedstudio.com/BeagleBone_Green_HDMI_Cape>`__) |
| 32 | +- PC (Windows or Linux) |
| 33 | +- Ethernet cables |
| 34 | +- Ethernet switch or ethernet router with DHCP service |
| 35 | +- SD card (minimum 16GB) |
| 36 | +- Audio Capture Device |
| 37 | + |
| 38 | +*********** |
| 39 | +Get Started |
| 40 | +*********** |
| 41 | + |
| 42 | +1. Flash an SD card with the :file:`tisdk-default-image`. User can download the :file:`tisdk-default-image` wic |
| 43 | + image from |__SDK_DOWNLOAD_URL__|. Please follow the instructions from here to :ref:`Flash an SD card <processor-sdk-linux-create-sd-card>`. |
| 44 | + |
| 45 | +2. Insert the SD card into the AM335x based board and set it to boot via SD card Boot mode. |
| 46 | + |
| 47 | +3. Connect an ethernet cable from your ethernet switch or router to the |
| 48 | + AM335x based board. |
| 49 | + |
| 50 | +4. Connect your PC to the same ethernet switch or router. |
| 51 | + |
| 52 | +5. Connect the UART to the PC's USB port. |
| 53 | + |
| 54 | +6. Open a terminal program (like TeraTerm or minicom) and connect to the |
| 55 | + serial port. Set the port to 115200bps, 8 bit, no parity, 1 stop bit, no flow control. |
| 56 | + |
| 57 | +7. Power on the AM335x based board. |
| 58 | + |
| 59 | +8. After the Linux boot completes, login as "root". Use the :command:`ifconfig` command |
| 60 | + to find out the IP address of the device. |
| 61 | + |
| 62 | +9. On the host PC, open a Internet Browser and enter in the following: ``http://<IP_ADDRESS_OF_AM335x_Board>:3000`` |
| 63 | + |
| 64 | +10. The following web page will be displayed, the home page shows as below. |
| 65 | + |
| 66 | +.. image:: /images/Webserver_home_page.PNG |
| 67 | + :alt: Webserver Demo Page |
| 68 | + :width: 75% |
| 69 | + |
| 70 | +************************* |
| 71 | +Audio Classification Demo |
| 72 | +************************* |
| 73 | + |
| 74 | +The web interface provides an audio classification demo that uses the integrated ARM analytics AI stack. |
| 75 | + |
| 76 | +.. image:: /images/Webserver_audio_classification.PNG |
| 77 | + :alt: Audio Classification Demo |
| 78 | + :width: 75% |
| 79 | + |
| 80 | +To use the demo: |
| 81 | + |
| 82 | +1. Connect a USB audio device (e.g., a USB headset) to the AM335x based board. |
| 83 | +2. Click the "Refresh Devices" button to detect the connected audio capture device. |
| 84 | +3. Select the desired audio capture device from the list of available devices. |
| 85 | +4. Click the "Start Classification" button to begin real-time audio classification. |
| 86 | +5. The "Live Classification" section will display the current classification, total classifications, unique classes, session time, and updates per minute. |
| 87 | +6. A "Classification History" log is also available, showing a timestamped record of classifications. |
| 88 | +7. Click the "Stop Classification" button to end the demo. |
| 89 | + |
| 90 | +**Technical Details** |
| 91 | + |
| 92 | +The audio classification demo leverages :ref:`NNStreamer <nnstreamer-label>`, a GStreamer-based neural network framework, to create and run the processing pipeline. |
| 93 | + |
| 94 | +* **Model:** The demo uses the YAMNet sound classification model (:file:`yamnet_audio_classification.tflite`). |
| 95 | +* **Deep Learning Runtime:** The model is executed using the :ref:`TensorFlow Lite <tflite-label>` runtime. |
| 96 | + |
| 97 | +**GStreamer Pipeline** |
| 98 | + |
| 99 | +The following GStreamer pipeline is used to process the audio from the microphone, run the inference, and decode the results: |
| 100 | + |
| 101 | +.. code-block:: bash |
| 102 | +
|
| 103 | + gst-launch-1.0 alsasrc device=<device> ! \ |
| 104 | + audioconvert ! \ |
| 105 | + audio/x-raw,format=S16LE,channels=1,rate=16000,layout=interleaved ! \ |
| 106 | + tensor_converter frames-per-tensor=3900 ! \ |
| 107 | + tensor_aggregator frames-in=3900 frames-out=15600 frames-flush=3900 frames-dim=1 ! \ |
| 108 | + tensor_transform mode=arithmetic option=typecast:float32,add:0.5,div:32767.5 ! \ |
| 109 | + tensor_transform mode=transpose option=1:0:2:3 ! \ |
| 110 | + queue leaky=2 max-size-buffers=10 ! \ |
| 111 | + tensor_filter framework=tensorflow2-lite model=/usr/share/oob-demo-assets/models/yamnet_audio_classification.tflite custom=Delegate:XNNPACK,NumThreads:2 ! \ |
| 112 | + tensor_decoder mode=image_labeling option1=/usr/share/oob-demo-assets/labels/yamnet_label_list.txt ! \ |
| 113 | + filesink buffer-mode=2 location=<fifo_path> |
| 114 | +
|
| 115 | +**************************** |
| 116 | +Live CPU Performance Metrics |
| 117 | +**************************** |
| 118 | + |
| 119 | +The web interface also provides a live view of the CPU performance metrics. |
| 120 | + |
| 121 | +.. image:: /images/Webserver_CPU_Performance.PNG |
| 122 | + :alt: CPU Performance Metrics |
| 123 | + :width: 75% |
| 124 | + |
| 125 | +This section includes: |
| 126 | + |
| 127 | +* **CPU Usage**: A real-time gauge showing the current CPU utilization. |
| 128 | +* **CPU History**: A graph displaying the CPU usage history over the last 5 minutes. |
| 129 | +* **Statistics**: Average and maximum CPU usage calculated for the data from CPU History data. |
| 130 | + |
| 131 | +********************* |
| 132 | +Software Architecture |
| 133 | +********************* |
| 134 | + |
| 135 | +The demo is comprised of three main components: a web interface, a backend web server, and a set of Linux applications. |
| 136 | + |
| 137 | +* **Web Interface (GUI):** A dynamic HTML page with JavaScript that runs in the user's browser. It provides the user interface for the audio classification demo and CPU performance metrics, making asynchronous requests to the web server for data updates. |
| 138 | + |
| 139 | +* **Web Server:** A lightweight HTTP server (e.g., Node.js) running on the AM335x's Arm A8 core. It serves the static web page and provides a simple REST API for the frontend to interact with the underlying Linux applications. |
| 140 | + |
| 141 | +* **Linux Applications:** |
| 142 | + * A C application that reads real-time system information (like CPU stats from :file:`/proc/stat`) and makes it available to the web server. |
| 143 | + - The audio classification demo, which is a GStreamer pipeline that leverages the NNStreamer framework. This pipeline reads from a USB audio device, processes the audio with the YAMNet model using the TensorFlow Lite runtime, and sends the classification results to the web server. |
| 144 | + |
| 145 | +******************* |
| 146 | +Directory Structure |
| 147 | +******************* |
| 148 | + |
| 149 | +Yocto recipe for building this demo can be found at `github:webserver-oob_git.bb <https://github.com/TexasInstruments/meta-tisdk/blob/scarthgap/meta-ti-foundational/recipes-demos/webserver-oob/webserver-oob_git.bb>`__. |
| 150 | + |
| 151 | +The source code for the demo can be found at `github/TexasInstruments/webserver-oob-demo <https://github.com/TexasInstruments/webserver-oob-demo>`__ . |
| 152 | +For instructions on building the utilities see the `README <https://github.com/TexasInstruments/webserver-oob-demo/blob/main/README.md>`__ file. |
| 153 | + |
| 154 | ++------+----------------------------------+---------------------------------------------+ |
| 155 | +| | **Directory Name** | **Description** | |
| 156 | ++======+==================================+=============================================+ |
| 157 | +| 1 | :file:`webserver_app/app` | GUI code (HTML, CSS, JavaScript) | |
| 158 | ++------+----------------------------------+---------------------------------------------+ |
| 159 | +| 2 | :file:`webserver_app/linux_app` | Linux application code (C code) | |
| 160 | ++------+----------------------------------+---------------------------------------------+ |
| 161 | +| 3 | :file:`webserver_app/webserver` | Web server code (Node.js) | |
| 162 | ++------+----------------------------------+---------------------------------------------+ |
0 commit comments