tflite
models, create custom DSP blocks and, finally, modify the C++ inferencing SDK.If you are looking for a more beginner-level tutorial, please head to the Sensor Fusion tutorial.softmax
layer), we cut the neural network somewhere at the end and we obtained the embeddings.
Neural Networks Embeddings
grind
, idle
, pump
and extract
). First, we are going to use a spectrogram DSP block and a NN classifier using two dense network. This first impulse will then be used to generate the embeddings and will be made available in a custom DSP block. Finally, we are going to train a fully connected layer using features coming from both the generated embeddings and a spectral feature DSP block.
We have develop two Edge Impulse public projects, one publicly available dataset and a Github repository containing the source code to help you follow the steps:
Coffee machine example using sensor fusion data sample with 1 audio channels and 3 accelerometer axis
Sensor fusion data sample with images and sensor data encoded as a time-series
Impulse for the first step
saved_model
). Extract the save_model directory and place it under the /input
repository.
Download Test Data: From the same dashboard, download the test or train data NPY file (input.npy
). Place this numpy array file under the /input
repository. This will allow us to generate a quantized version of the tflite embeddings. Ideally choose the test data if you have some data available.
Download saved_model and X_train.npy
saved_model_to_embeddings.py
script for this conversion for a better understanding.
dsp.py
script:
dsp-blocks/features-from-audio-embeddings/dsp.py
to match your DSP configuration:
get_tflite_implementation
function returns the TFLite model. Note that the on-device implementation will not be correct initially when generating the C++ library, as only the neural network part is compiled. We will fix this in the final exported C++ Library.
Now publish your new custom DSP block.
Impulse for the second step
Final fully connected layers
quantized
vs. float32
).example-cpp
folder for easy access.model-parameters/model_variables.h
file of the exported C++ library, add a forward declaration for the custom DSP block you created.&extract_tflite_eon_features
into &custom_sensor_fusion_features
in the ei_dsp_blocks
object.
main.cpp
file of the C++ library, implement the custom_sensor_fusion_features block. This block should:
features[]
array in source/main.cpp
make -j
in this directory to compile the project. If you encounter any OOM memory error try make -j4
(replace 4 with the number of cores available)./build/app
to run the application