Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lrcn model to onnx error #145

Open
Magsun opened this issue May 18, 2020 · 0 comments
Open

lrcn model to onnx error #145

Magsun opened this issue May 18, 2020 · 0 comments

Comments

@Magsun
Copy link

Magsun commented May 18, 2020

@harvitronix hello Harvey, thanks to your really good tutorial for video classification.

I followed your instruction to train my own lrcn video classification model and it works well under tensorflow&keras. But when I tried to convert this .hdf5 model to .onnx, I met this error below:

env info:
tf-gpu 1.14
tb-nightly
cuda10.1
onnx 1.7.0
keras2onnx 1.6.1
python3.6

Traceback (most recent call last):
File "/workspace/h52onnx.py", line 15, in
onnx_model = keras2onnx.convert_keras(model, model.name)
File "/opt/conda/lib/python3.6/site-packages/keras2onnx/main.py", line 95, in convert_keras
return convert_topology(topology, name, doc_string, target_opset, channel_first_inputs)
File "/opt/conda/lib/python3.6/site-packages/keras2onnx/topology.py", line 243, in convert_topology
get_converter(operator.type)(scope, operator, container)
File "/opt/conda/lib/python3.6/site-packages/keras2onnx/ke2onnx/main.py", line 94, in convert_keras_flatten
shape_len = len(iop.input_shape)
File "/opt/conda/lib/python3.6/site-packages/keras/engine/base_layer.py", line 918, in input_shape
raise AttributeError('The layer has never been called '
AttributeError: The layer has never been called and thus has no defined input shape.

image

For your information, I only changed input size from self.input_shape = (seq_length, 80, 80, 3) to self.input_shape = (seq_length, 320, 320, 3).

Convert code listed below:

import keras
import keras2onnx
import onnx
from keras.models import load_model

model = load_model('/workspace/lrcn-images.050-1.443.hdf5')
onnx_model = keras2onnx.convert_keras(model, model.name)
temp_model_file = '/workspace/model.onnx'
onnx.save_model(onnx_model, temp_model_file)

Kindly help. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant