Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F five-video-classification-methods
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 47
    • Issues 47
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Matt Harvey
  • five-video-classification-methods
  • Issues
  • #145
Closed
Open
Issue created May 18, 2020 by Magsun@Magsun

lrcn model to onnx error

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

Assignee
Assign to
Time tracking