# Tensorflow Edge Optimization (.h5 to C code)

# Background

In this guide you will learn how to convert a Tensorflow/Keras .h5 model to C code so that you can run it on any compute platform ranging from microcontrollers to PCs to smartphones (iOS and Android).

The Edge Optimization is compatible with Tensorflow/Keras .h5 models generated with a Tensorflow backend of version 2.x. Models containing unsupported layers will fail to convert. See supported layers and activation functions below.

Supported Layers & Functions

# Open your .h5 model

Open Imagimob Studio and open a workspace containing a .h5 file.

Double click on a .h5 file that has been trained using tensorflow and go to the Edge tab.

In the Architecture field we can chose to optimize our Edge model (C-code) for different target architectures. Let's keep it at ANSI, this way the model can be compiled for any platform.

The two fields Output Directory and C Prefix control the output directory and the generated C API for the generated Edge model. Let's leave both these fields as shown above.

# Build Edge

Now we are ready to Build the Edge model.

Click on "Build Edge" at bottom.

In a matter of seconds the Edge model has been generated and a report is generated for us. Here we can see how much memory this model will use when deployed on a device.

Let's click "OK".

Now we have finished converting our tensorflow model into a Edge model that consumes a fraction of the memory/processing power during runtime and can run on any embedded platform!

Back to the start page