Unexpected keyword argument 'ragged' in Keras

So I tried link above which you have mentioned teachable machine
As it turns out model you have exported is from tensorflow.keras and not directly from keras API. These two are different. So while loading it might be using tf.ragged tensors that might not be compatible with keras API.

Soulution to your issue:

Don't import keras directly as your model is saved with Tensorflow's keras high level api. Change all your imports to tensorflow.keras

Change:

from keras.preprocessing.image import img_to_array
from keras.models import load_model

to this:

from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model

It will solve your issue.

EDIT :
All of your imports, either should be from Keras or tensorflow.keras. Although being same API few things are different which creates these kind of issues. Also for tensorflow backend tf.keras is preferred, because Keras 2.3.0 is last major release which will support backends other than tensorflow.

This release brings the API in sync with the tf.keras API as of TensorFlow 2.0. However note that it does not support most TensorFlow 2.0 features, in particular eager execution. If you need these features, use tf.keras. This is also the last major release of multi-backend Keras. Going forward, we recommend that users consider switching their Keras code to tf.keras in TensorFlow 2.0.


Like @Vivek Mehta said, first change load_model from keras to tensorflow.keras i.e

from tensorflow.keras.models import load_model

But even then if the model loading shows error like KeyError: 'sample_weight_mode' then do the following

from tensorflow.keras.models import load_model

model = load_model('model.h5', compile = False)