cancel
Showing results for 
Search instead for 
Did you mean: 

UNABLE TO CONVERT TFLITE MODEL FROM KERAS MODEL

ShivaRagu
Senior

Hi,

Am trying to create the ASC model which is existing in FP-AI-SENSING1 Pack. When I was converting from keras model to TFlite model am getting below error. Am using the same code which is in the pack, am not changing anything. Even the audio files am using the same.

Anyone can help?

ERROR-

AttributeError: type object 'TFLiteConverter' has no attribute 'from_keras_model'

Below is the code which am using to convert into TFlite model.

def representative_dataset_gen():

    for i in range(len(x_train_r)):

        yield [x_train_r[i].reshape((1, ) + x_train_r[i].shape)]

converter = tf.lite.TFLiteConverter.from_keras_model(out_dir + "Outputmodel.h5" )

converter.optimizations = [tf.lite.Optimize.DEFAULT]

converter.representative_dataset = representative_dataset_gen

converter.target_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]

converter.inference_input_type = tf.int8

converter.inference_output_type = tf.int8

tflite_model = converter.convert()

with open(out_dir + 'model.tflite','wb') as f:

    f.write(tflite_model)

    print("TFlite model saved")

    

Regards,

shankari.

0 REPLIES 0