OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.64k stars 2.19k forks source link

Converting Trained Inception model to Tensorflow ERROR #354

Open ola0x opened 5 years ago

ola0x commented 5 years ago

When i tried converting my trained model (.h5) to tensorflow version ( .pb ), i got the flowing error.

File "C:\Users\hp\Documents\ml\New Model\CustomModel.py", line 13, in predictor.save_model_to_tensorflow(new_model_folder= os.path.join(execution_path, "tensorflow_model"), new_model_name="idenprof_resnet_tensorflow.pb") File "C:\Program Files\Python37\lib\site-packages\imageai\Prediction\Custom__init__.py", line 589, in save_model_to_tensorflow main_graph = graph_util.convert_variables_to_constants(sess, init_graph, out_nodes) File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func return func(*args, **kwargs) File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\framework\graph_util_impl.py", line 297, in convert_variables_to_constants source_op_name = get_input_name(node) File "C:\Program Files\Python37\lib\site-packages\tensorflow\python\framework\graph_util_impl.py", line 254, in get_input_name raise ValueError("Tensor name '{0}' is invalid.".format(node.input[0])) ValueError: Tensor name 'batch_normalization/cond/ReadVariableOp/Switch:1' is invalid.

rola93 commented 5 years ago

What version of ImageAI/Keras/Tensorflow are you using? can you share your code?

Consider that the model for object detection provided by ImageAI is jus a Keras model, you can look how is this loaded on the evaluation method, and then all you need is just to import it.

anchu-simplecrm commented 5 years ago

i had same issue , please update your keras and imageai to the latest version and use tensorflow =1.15.0rc0....may be this will work

Lannist commented 5 years ago

Did you solve the problem at last? I met the same problem.

anchu-simplecrm commented 5 years ago

yes

Lannist commented 5 years ago

Can you tell me how to solve the problem?Thx

anchu-simplecrm commented 5 years ago

can u tell us version of tensorflow,imageAI,keras etc

Lannist commented 5 years ago

tensorflow-gpu = 1.14.0, keras = 2.2.4 TensorRt = 6.0.1.5