Genki ML Format

From ONNX and Keras

Models are exported using the genkiml CLI. The input is a model/checkpoint file and the output is the exported version of the model along with C++ code to run and easily integrate it in an existing codebase. This tool has support ONNX and Keras models

After installing the required packages run (see Installation CLI)

python genkiml.py path/to/model

This will output a zip archive to the desired --output-path. If no output path is provided the zip archive is put into the current folder.

Example using a Keras model

Let's define a simple fully connected network with an input with the shape (batch_size, 100) and 2 outputs and save it to disk

import tensorflow as tf

model = tf.keras.models.Sequential([
    tf.keras.layers.Dense(256, input_shape=(100,)),
    tf.keras.layers.ReLU(),
    tf.keras.layers.Dense(256),
    tf.keras.layers.ReLU(),
    tf.keras.layers.Dense(2)
])
model.save("fully_connected_keras_model")

Then simply point the genkiml CLI to the model.

python genkiml.py fully_connected_keras_model

This will output a file in the current folder, genkiml_cpp.zip, that contains the exported model along with the runtime.

Previous
Cross-platform C++ Runtime