Open anilsathyan7 opened 4 years ago
Hi! Сan you check if this is what you were looking for? SINet_320_opbnup.h5.zip
The structure seems to be fine; but how to load this model with channel first nodes and lambda layers in tf.keras inference?
I got the following error during load:-
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/core.py:1045: UserWarning: onnx2keras.convolution_layers is not loaded, but a Lambda layer uses it. It may cause errors. , UserWarning)
ValueError Traceback (most recent call last)
in () 2 import tensorflow as tf 3 ----> 4 model=tf.keras.models.load_model('/content/SINet_320_opbnup.h5') 12 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/generic_utils.py in func_load(code, defaults, closure, globs) 455 except (UnicodeEncodeError, binascii.Error): 456 raw_code = code.encode('raw_unicode_escape') --> 457 code = marshal.loads(raw_code) 458 if globs is None: 459 globs = globals() ValueError: bad marshal data (unknown type code)
Ideally, we want NHWC format with bilinear upsample, so that we can deploy them in tflite format ...
Ohh. Unfortunately, it turned out to be not as easy as I thought. I can highlight the following problems:
I think the 'resize' operator in onnx seems to handle bilinear resize functionality. It seems to give good results during testing/inference, with align corners=True. Earlier it used to be upsample layer(ie. nearest only). Similarly onnx seems to support reduce max operation. Keras also seems to have these layers anyway, so are they just integration issues?
I think this is primarily a lack of time. ReduceMax operation was added yesterday. I will look better to onnx "Resize" operation and maybe will add its support to the library. There is no similar functionality in keras. I'll see what can be done about it.
I was trying to convert a pytorch model into keras via onnx. The pytorch model was successfully converted to onnx format. I tried two versions of the model:
In both cases i got same errors, if i set change_ordering=False Code:-
Error:-
If i set change_ordering=True, i get another error:-
Models:-
SINet_320.zip
I ran the model checker successfully i.e onnx.checker.check_model(onnx_model) The original pytorch model contains PRelu activations. How can we fix this issue and convert the model into keras format??