4

Trying to convert a keras model (Thumbs.h5) into an onnx model on Google Colab, however I am getting an "AttributeError: module 'tensorflow.python.keras' has no attribute 'applications'" error when I run the code.

My code:


from tensorflow.python.keras import backend as K
from tensorflow.python.keras.models import load_model
import onnx
import keras2onnx

onnx_model_name = 'fish-resnet50.onnx'

model = load_model('model-resnet50-final.h5')
onnx_model = keras2onnx.convert_keras(model, model.name)
onnx.save_model(onnx_model, onnx_model_name)

What I've tried:

  • Updating keras with !pip install keras --upgrade (already updated)
  • Running it locally with a jupyter notebook on my M1 Mac (V12.4) to get the same error

Pointers or solutions greatly appreciated.

2
  • Solved by specifying path to the entire folder rather than the .h5 file! Commented Jul 8, 2022 at 11:23
  • 2
    What? How could that solve the issue, doesn't the error trigger when you import keras2onnx? Commented Aug 25, 2022 at 2:43

1 Answer 1

1

As per the documentation

keras2onnx has been tested on Python 3.5 - 3.8, with tensorflow 1.x/2.0 - 2.2

So install compatible version of tensorflow. Also keras-onnx is not under active development so use tf2onnx as per the documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.