tohinz / SVHN-Classifier

Simple classifier to classify SVHN images, based on Keras with the Tensorflow backend.
17 stars 4 forks source link

Error when using newer versions of tensorflow (>2.0.0) #3

Open emile-p opened 4 years ago

emile-p commented 4 years ago

When running python svhn_classifier.py --predict --model weights.hdf5 --img_path ../images/ I get the following error:

Traceback (most recent call last):
  File "svhn_classifier.py", line 174, in <module>
    predict(FLAGS.model, FLAGS.img_path, FLAGS.batch_size)
  File "svhn_classifier.py", line 153, in predict
    model = keras.models.load_model(model)
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 184, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 177, in load_model_from_hdf5
    model = model_config_lib.model_from_config(model_config,
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/model_config.py", line 55, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/layers/serialization.py", line 105, in deserialize
    return deserialize_keras_object(
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 361, in deserialize_keras_object
    (cls, cls_config) = class_and_config_for_serialized_keras_object(
  File "/home/emile/.local/lib/python3.8/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 325, in class_and_config_for_serialized_keras_object
    for key, item in cls_config.items():
AttributeError: 'list' object has no attribute 'items'

Apparently this is caused due to the model (weights.hdf5) being saved using an older version of tensorflow (2.0.0 or older). Tensorflow 2.0.0 does not seem to be available for newer python versions (>3.7).

Is it possible for you to update the weights using newer versions for python and tensorflow?