4

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 ?

thisisjaymehta
  • 614
  • 1
  • 12
  • 26
Sarra_LKSC
  • 41
  • 3
  • What version of Tensorflow are you using? – Johiasburg Frowell Sep 01 '20 at 23:13
  • I had this problem using tensorflow 2.0.0, while gcp (google) tensorflow version was 2.2. I upgraded to tensorflow 2.2.3 and it went away. – DanDy Oct 21 '20 at 19:26
  • Usually you will get this error when you pass string representation of float to int, you can try these solutions https://stackoverflow.com/questions/1841565/ –  Dec 13 '20 at 14:36

2 Answers2

0
  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.
0

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

Space4VV
  • 125
  • 9