mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 14:03:55 +01:00
It turns out that the fix for the missing terminating newline is not
robust. This hopefully fixes the issue and resolves the following
error message:
In file included from /home/maribu/Repos/software/RIOT/tests/pkg_emlearn/main.c:25:
/home/maribu/Repos/software/RIOT/tests/pkg_emlearn/model.h:7221:36: error: stray '\' in program
7221 | /* fix for no newline at eof */\n
| ^
/home/maribu/Repos/software/RIOT/tests/pkg_emlearn/model.h:7221:38: error: expected ';' before '_Alignas'
7221 | /* fix for no newline at eof */\n
| ^
| ;
Emlearn package test application
This application shows how to use a machine learning model with emlearn on RIOT in order to predict a value from a hand written digit image. The model is a Scikit-Learn random forest estimator trained on the MNIST dataset.
Expected output
The default digit to predict is a hand-written '6', so the application output is the following:
Predicted digit: 6
Use the Python scripts
The application comes with 3 Python scripts:
generate_digit.pyis used to generate a new digit file. This file is embedded in the firmware image and is used as input for the inference engine. Use the-ioption to select a different digit. For example, the following command:
will generate a digit containing a '9'. The digit is displayed at the end of the script so one knows which digit is stored. Note that each time a new digit is generated, the firmware image must be rebuilt to include this new digit.$ ./generate_digit.py -i 1train_model.pyis used to train a new Scikit-Learn Random Forest estimator. The trained model is stored in themodelbinary file.
will just train the model.$ ./train_model.pygenerate_model.pyis used to generate thesonar.hheader file from themodelbinary file. The script is called automatically by the build system when themodelbinary file is updated.