How to convert .lite to .tflite file to be used in Android app?

Question/Issue:
How to convert .lite to .tflite file to be used in Android app?
Project ID:
Using the file as a wake-word in a project/app for the visually impaired.
Context/Use case:
Wake-word

A .lite file is the same as a .tflite file. You can simply rename the extension. See this thread for more info: android - What is the difference between the .lite and the .tflite formats - Stack Overflow.

Note that you will need to make sure that the version of TFLite used to convert the model to .lite/.tflite is the same version of the TFLite used in your Android App.

hi @shawn_edgeimpulse

  1. whats is the difference .lite and .eim file?why is we can’t directly use .lite for example using python linux sdk?
  2. can we see what’s inside that both file?

regards,

Hi @devis,

You can read more about eim files here: Edge Impulse for Linux - Edge Impulse Documentation

EIM files are compiled models (including DSP) and hardware optimized for Linux-based systems.
TFLite models only contain the Neural Network part, you can load them using the TF Lite interpreter.

Aurelien

1 Like

Hi, Thanks for your responses.
I used the float32 .lite wake-word model file (c.f. Login - Edge Impulse) & loaded in an android app with the following block of code:

private static MappedByteBuffer loadModelFile(AssetManager assets, String modelFilename)
throws IOException {
AssetFileDescriptor fileDescriptor = assets.openFd(modelFilename);
FileInputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel = inputStream.getChannel();
long startOffset = fileDescriptor.getStartOffset();
long declaredLength = fileDescriptor.getDeclaredLength();
return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength);
}

However, this gives me following errors when I run the Android app with various files:

Internal error: Unexpected failure when preparing tensor allocations: tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (172240 != 650)
Node number 0 (RESHAPE) failed to prepare.

Internal error: Unexpected failure when preparing tensor allocations: tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (180320 != 650)
Node number 0 (RESHAPE) failed to prepare.

tensorflow/lite/kernels/reshape.cc:69 num_input_elements != num_output_elements (16164 != 650)
Node number 0 (RESHAPE) failed to prepare.

What did I miss here??