Open msquigle opened 3 years ago
Can you try tensorflow 2.2.0 and keras2onnx from master branch?
Using tensorflow 2.2.0 and the latest pypi release of keras2onnx, I get the error site-packages\tensorflow\python\keras\utils\generic_utils.py", line 321, in class_and_config_for_serialized_keras_object raise ValueError('Unknown ' + printable_module_name + ': ' + class_name) ValueError: Unknown layer: Functional
Issue: when I run the code below, onnx_model_name = 'classify.onnx'
model = load_model('path_to_folder/saved_models/final') onnx_model = keras2onnx.convert_keras(model, model.name) keras2onnx.save_model(onnx_model, os.path.join('saved_models', onnx_model_name))
Even I ran into the same error:
Traceback (most recent call last):
File "/snap/pycharm-professional/230/plugins/python/helpers/pydev/pydevd.py", line 1477, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/snap/pycharm-professional/230/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "correct_image_classification/test.py", line 38, in
I am using, tensorflow==2.3.0 tensorflow image classification problem
using tensorflow 2.3.1 and installing keras2onnx from source i was able to convert mobilenet keras model to onnx. But when i am running in open CV readnetfromonnx it is crashing. Did not happen with prior conversions. Earlier i was facing this issue ValueError: Unable to find out a correct type for tensor type = 20 of conv2d_6/Conv2D/ReadVariableOp/resource:0 but after installing keras2onnx it converted but not able to run the onnx. Any leads @jiafatom Thanks. Here's the attachment of my converted onnx. onnx.zip
Using tensorflow 2.2.0 and the latest pypi release of keras2onnx, I get the error site-packages\tensorflow\python\keras\utils\generic_utils.py", line 321, in class_and_config_for_serialized_keras_object raise ValueError('Unknown ' + printable_module_name + ': ' + class_name) ValueError: Unknown layer: Functional
@msquigle because you would have trained with new tf version and when u load model with old tf model it will throw this unknown layer error. Run with tf 2.3.1 version it should load the model. And install keras2onnx from source. For me these steps converted my keras model to onnx but not able to run onnx model now.
Seems that your model is converted. Now the issue can be in (1) the onnx model (2) in open CV readnetfromonnx To verify (1), can you try running your onnx model via onnxruntime? We have many tests in the repo, so you can find those examples.
Issue: When trying to convert the attached model using the following script
import tensorflow as tf import onnx import keras2onnx keras_model = tf.keras.models.load_model(mobilenet_ssd.h5, compile=False) model_proto = keras2onnx.convert_keras(keras_model, target_opset=11) with open(outfile, "wb") as f: f.write(model_proto.SerializeToString())
the following error is received site-packages\keras2onnx_parser_tf.py", line 47, in infer_variable_type raise ValueError( ValueError: Unable to find out a correct type for tensor type = 20 of conv2d_6/Conv2D/ReadVariableOp/resource:0
The model is a standard mobilenet ssd and it seems that this type of error should not arise. mobilenet_ssd.zip