简体   繁体   中英

AttributeError: module 'tensorflow.python.keras' has no attribute 'applications'

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM