Closed norbaf78 closed 4 years ago
Sorry for the late answer, I'll try to do that and let you know.
Ok, it looks like it's an issue with tensorflow that is solved in the nightly build.
This works for me (in Colab):
!pip install tf-nightly
!wget https://github.com/douglas125/SpeechCmdRecognition/blob/master/model-attRNN.h5?raw=true
!wget -q https://raw.githubusercontent.com/douglas125/SpeechCmdRecognition/master/SpeechModels.py
!pip install kapre==0.2
!mv model-attRNN.h5?raw=true model-attRNN.h5
import tensorflow as tf
from tensorflow.keras.models import load_model
from kapre.time_frequency import Melspectrogram, Spectrogram
from kapre.utils import Normalization2D
import SpeechModels
model = load_model('model-attRNN.h5', custom_objects={'Melspectrogram': Melspectrogram, 'Normalization2D': Normalization2D })
model.save('att_rnn')
saved_model_dir = 'att_rnn'
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir) # path to the SavedModel directory
tflite_model = converter.convert()
# Save the model.
with open('attRNN.tflite', 'wb') as f:
f.write(tflite_model)
I'm closing this for now, but feel free to reopen if there are other issues.
I have tried to conver the created model in tflite but with no result. Someone can provide me if converting to tflite is possible and how do it. Here what I have tried with no result.
converter = tf.lite.TFLiteConverter.from_keras_model(model) tflite_model = converter.convert()
INFO:tensorflow:Assets written to: attRNNModel/1/assets ValueError Traceback (most recent call last)