source code for the project in TinyML course
A list of CSV files from the GitHub repo "tinyml-motor-fault-detection " by "ahmed-abdat". We copied the dataset from "dataset/edge_impulse_format/"
It contains two set accelerator measurements in all three cardinal directions (X,Y,Z) for both faulty and normal drones. Each measurement is exactly five seconds long with a measurement frequency of 1000 Hz. Since the set of faulty measurements has 117 files and the normal set 103, we can work with 1.100.000 3D data points for our training process.
- Create a Fast Fourier Transform (FFT) for all 220 files
- Pick the top few frequencies with the highes amplitude per FFT
- Filter the collection per axis based on a chosen threshold (everything below gets ignored)
- Collect most common frequencies among all files per axis.
- These frequencies' amplitudes can be used as an input for a NNN
visualization.ipynb: We have included a visualization jupyter notebook. This is not part of any model creation process. It can be executed to see how the data looks like. This was helpful for us to recognize differences in the dataset between faulty and normal.
augmentation.py: This script is the first that should be executed to generate extra data to train the model. The original data set only contains 220 files which store a five-second interval. By clipping the data into two-second intervals with a moving window with a step size of one second, every file is split into four two-second intervals. After that, every interval gets a little bit of gaussian noise added to it. This noise addition is two separate times per interval, so we generate eight files from one original file. That way we have 1760 data points to train our models.
preprocessing.py: Every model need the input data formated / prepared in a specific way. To set up this preprocessing once, execute this script which will run the preprocessing scripts per model. More information about that in the respective following subchapter.
communication_uart.py: Once the model is trained, converted, compiled, flashed and running on the microcontroller, we need to send data to it, so that it can run the inference. When running this script the user is prompted to select the current model, because every model has slight different parameter when sending data (primarily buffer size).
model_converter.py: The final quantized tflite models are stored in the models/ directory in the root of the project. However, the microcontroller can not reed this format. Because of this we need to convert it into a C++ source file which can be compiled by the esp32c3 compiler. This Python script handles all the important, conversion, renaming and integration of the model.cc file form the corresponding tflite file. Similar to the communication_uart.py script this script will prompt the user to choose the correct model.