1.. _tensorflow_magic_wand: 2 3TensorFlow Lite Micro Magic Wand sample 4####################################### 5 6Overview 7******** 8 9This sample application shows how to use TensorFlow Lite Micro 10to run a 20 kilobyte neural network model that recognizes gestures 11from an accelerometer. 12 13.. Note:: 14 This README and sample have been modified from 15 `the TensorFlow Magic Wand sample for Zephyr`_ and 16 `the Antmicro tutorial on Renode emulation for TensorFlow`_. 17 18.. _the TensorFlow Magic Wand sample for Zephyr: 19 https://github.com/tensorflow/tflite-micro/tree/main/tensorflow/lite/micro/examples/magic_wand 20 21.. _the Antmicro tutorial on Renode emulation for TensorFlow: 22 https://github.com/antmicro/litex-vexriscv-tensorflow-lite-demo 23 24Building and Running 25******************** 26 27The application can be built for the :ref:`litex-vexriscv` for 28emulation in Renode as follows: 29 30.. zephyr-app-commands:: 31 :zephyr-app: samples/modules/tflite-micro/magic_wand 32 :host-os: unix 33 :board: litex_vexriscv 34 :goals: build 35 :compact: 36 37Once the application is built, `download and install Renode 1.12 or higher as a package`_ 38following the instructions in the `Renode GitHub README`_ and 39start the emulator: 40 41.. code-block:: console 42 43 renode -e "set zephyr_elf @./build/zephyr/zephyr.elf; s @./samples/modules/tflite-micro/magic_wand/renode/litex-vexriscv-tflite.resc" 44 45.. _download and install Renode 1.12 or higher as a package: 46 https://github.com/renode/renode/releases/ 47 48.. _Renode GitHub README: 49 https://github.com/renode/renode/blob/master/README.rst 50 51Sample Output 52============= 53 54The Renode-emulated LiteX/VexRiscv board is fed data that the 55application recognizes as a series of alternating ring and slope 56gestures. 57 58.. code-block:: console 59 60 Got accelerometer, label: accel-0 61 62 RING: 63 * 64 * * 65 * * 66 * * 67 * * 68 * * 69 * 70 71 SLOPE: 72 * 73 * 74 * 75 * 76 * 77 * 78 * 79 * * * * * * * * 80 81 RING: 82 * 83 * * 84 * * 85 * * 86 * * 87 * * 88 * 89 90 SLOPE: 91 * 92 * 93 * 94 * 95 * 96 * 97 * 98 * * * * * * * * 99 100Modifying Sample for Your Own Project 101************************************* 102 103It is recommended that you copy and modify one of the two TensorFlow 104samples when creating your own TensorFlow project. To build with 105TensorFlow, you must enable the below Kconfig options in your :file:`prj.conf`: 106 107.. code-block:: kconfig 108 109 CONFIG_CPP=y 110 CONFIG_NEWLIB_LIBC=y 111 CONFIG_TENSORFLOW_LITE_MICRO=y 112 113Training 114******** 115Follow the instructions in the :file:`train/` directory to train your 116own model for use in the sample. 117