0

I am trying to predict the label of an input image based on trained model but am getting the error of 'str' object has no attribute 'decode' at the code below.

sm = tf.keras.models.load_model('model.h5')

I can not understand what is it saying and how to resolve it.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • are you sure that your model is `model.h5` but `model.hdf5` – Darshan Dec 02 '20 at 14:30
  • 1
    Have a look [here.](https://stackoverflow.com/questions/53740577/does-any-one-got-attributeerror-str-object-has-no-attribute-decode-whi) – Darshan Dec 02 '20 at 14:34
  • Please notice that any code that comes *after* the error is irrelevant to the issue (never executed) and it should *not* be included here as it just creates unnecessary clutter (edited out); code here is supposed to be *minimal*, among [other things](https://stackoverflow.com/help/minimal-reproducible-example). – desertnaut Dec 02 '20 at 22:46
  • That question has been refered in questions like this: https://stackoverflow.com/questions/53740577/does-any-one-got-attributeerror-str-object-has-no-attribute-decode-whi – Miguel Rueda Feb 03 '21 at 17:02

1 Answers1

0

You could follow some steps like:

  1. Check your h5py lib version since there are some backward compatibility issues.
  2. Try to use explitly you model and then load its weights using model.load_weights function.
Miguel Rueda
  • 478
  • 1
  • 6
  • 13