-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
inputs.size() > 0 in function 'getMemoryShapes' #14290
Copy link
Copy link
Closed
Labels
Description
Strange error when I am trying to convert model from keras to onnx and run through opencv dnn.
- OpenCV == 4.1.0
- Operating System / Platform == Ubuntu 16.04 / 64 Bit
- Compiler == conda 4.6.11 / libgcc-ng 8.2.0
- onnxmltools == 1.4.0 / onnx = 1.4.1
- keras == 2.2.4 / tensorflow == 1.13.1
import os
os.environ['CUDA_VISIBLE_DEVICES'] = ''
import numpy as np
from keras import regularizers
from keras import initializers
from keras import layers
from keras.models import Model
def get_model():
inp = layers.Input(shape=(48,80,1))
x = layers.Conv2D(32, 7)(inp)
x = layers.BatchNormalization()(x)
out = layers.ReLU()(x)
return Model(inp, out)
if __name__ == '__main__':
model = get_model()
model.compile(optimizer='adam', loss='mse')
X = np.random.rand(32, 48, 80, 1)
y = np.random.rand(32, 42, 74, 32)
model.fit(X, y, epochs=1, validation_data=(X, y))
model.save('model.h5')
import onnxmltools
from keras.models import load_model
model = load_model('model.h5')
onnx_model = onnxmltools.convert_keras(model)
onnxmltools.utils.save_model(onnx_model, 'model.onnx')
import cv2
cv2.dnn.readNetFromONNX('model.onnx')
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-3-6da663bc3421> in <module>
----> 1 cv2.dnn.readNetFromONNX("models/eyegaze_reduced.onnx")
error: OpenCV(4.1.0) ../modules/dnn/src/layers/permute_layer.cpp:124: error: (-215:Assertion failed) inputs.size() > 0 in function 'getMemoryShapes'
Reactions are currently unavailable