Error while loading trained Tensorflow Saved Model on pycharm. ValueError: invalid literal for int() with base 10: 'class_name'

Viewed 495

Context: I have trained a model which consist in an image classifier.This model consist in a TF CNN and has been trained online (with google colaboratory) I then downloaded it as a tf.savemodel object. I would like to deploy this trained model on a PyQt5 Desktop app.

Problem: When I try to load my trained model in my code in PyCharm (2020.1.3) I get the following error :

ValueError: invalid literal for int() with base 10: 'class_name'

During handling of the above exception, another exception occurred:

ValueError: Error converting shape to a TensorShape: invalid literal
for int() with base 10: 'class_name'.

code used to load model:

model1=tf.keras.models.load_model(r'C:\Users\user\Desktop\UNI\L3\saved_models\model7')

SIDE NOTE: When I run the same line on colab the model is successfully loaded into the notebook.

Questions:
-What does the error mean?
-Why does it work on colab and not in my IDE?
-How can I fix this in order to load and use the trained model in my app ?

2 Answers
  1. Works on colab but not on IDE because you have different version of tenserflow installed at both postion
  2. Changing Tensorflow version from 2.0.0 to 2.3.1 solve the issue.

check the version of the TF in the current system, you might have trained with 2.1 and tried to load the model with a 2.3 version

Related