Code Monkey home page Code Monkey logo

domenicostefani / deep-classf-runtime-wrappers Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 236.63 MB

Classification wrappers for 4 Deep Learning Embedded Runtimes for Music Information Retrieval, plus utilities to convert a TensorFlow Model

License: GNU General Public License v3.0

CMake 0.64% Shell 0.18% C++ 97.85% C 1.09% Jupyter Notebook 0.22% Python 0.01%
wrappers classification deep-learning tensorflow-lite rtneural torchscript onnx-runtime mir music-information-retrieval

deep-classf-runtime-wrappers's Introduction

Deep Learning Runtime wrappers for Embedded Real-time Audio Classification

Classification wrappers that expose the same API for the following Deep Learning Embedded Runtimes:

  • TensorFlow Lite 2.7.0
  • Torchscript/Pytorch C++
  • ONNX Runtime
  • RTNeural

We also provide an improved wrapper for TFlite 2.5.3 with support for 2d input. However, that version of the API is different and not compatible with the others

Each folder contains scripts and library binaries to compile libraries for the Elk Audio OS

API functions

/** Dynamically allocate an instance of a classifier object (do not use in real time threads!) */
ClassifierPtr createClassifier(const std::string &filename, bool verbose = false);

/** Feed a feature array (C Array) to the model, perform inference and return the prediction */
int classify(ClassifierPtr cls, const float featureVector[], size_t numFeatures, float outputVector[], size_t numClasses);

template<std::size_t IN_SIZE, std::size_t OUT_SIZE>
int classify(ClassifierPtr cls, std::array<float,IN_SIZE>& featureArray, std::array<float,OUT_SIZE>& outputArray);

/** Free the classifier memory (do not use in real time threads) */
void deleteClassifier(ClassifierPtr cls);

Real-time Safety

The classify(...) function is meant to be called from real-time threads (e.g., audio thread) so it is meant to be real-time safe, if the interpreter at hand allows for rt-safe inference. RT-safety was tested for:

  • TensorFlow Lite
  • TorchScript (Yes, but classify must be called once during the first call of the audio processing function, otherwise it allocates memory. See this)
  • Onnx Runtime (Yes, but same as TorchScript. See this)
  • RtNeural

The createClassifier(...) and deleteClassifier(...) functions will mess with memory allocation and are definitely not meant to be called from real-time thread, but only once on program start and end.

Model Conversion Utils

The interactive notebook tensorflow_model_conversion.ipynb contains utilities to convert a TensorFlow model to the formats accepted by each runtime.

Domenico Stefani, Simone Peroni 2022

deep-classf-runtime-wrappers's People

Contributors

domenicostefani avatar simoneperoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cimil

deep-classf-runtime-wrappers's Issues

Can the results of the paper be extended to other neural networks such as the UNet ?

Hello Domenico,
Your "A COMPARISON OF DEEP LEARNING INFERENCE ENGINES FOR EMBEDDED REAL-TIME AUDIO CLASSIFICATION" paper was a great read ๐Ÿ‘. The paper already mentions that future work will focus on more complex models (other than feedforward neural networks). But I am wondering about your intuition/ opinion on whether the presented performance results can be extended to other neural network architectures such the U-Net? I am currently exploring inference engine performances for a real-time application based on the U-Net architecture. I was feeling strongly about ONNX but it seems TFlite is a good compromise between ease of use and performance.
Thank you in advance :))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.