error: (-215:Assertion failed) (int)_numAxes == inp0.dims in function 'cv::dnn::PermuteLayerImpl::finalize'

asked 2019-04-10 08:25:03 -0500

Maxim Roshior gravatar image

updated 2019-04-13 03:44:30 -0500

berak gravatar image

Hello, i am train keras model, after that i am convert keras model to pb model and try to use pb model via openCV dnn model by:

liveness_pb = r'.\pb\liveness_8_batch_1_epoch_test2.pb' modelCV = cv2.dnn.readNetFromTensorflow(liveness_pb)

prepare image and:

modelCV.setInput(face)
out = modelCV.forward()

but then get next error:

OpenCV(4.0.1) C:\projects\opencv-python\opencv\modules\dnn\src\layers\permute_layer.cpp:173: error: (-215:Assertion failed) (int)_numAxes == inp0.dims in function 'cv::dnn::PermuteLayerImpl::finalize'

can someone explain what i am doing wrong? and how to fix it?

edit retag flag offensive close merge delete

Comments

Can you provide a reproducer? In example, upload a .pb file?

dkurt gravatar imagedkurt ( 2019-04-10 08:41:40 -0500 )edit

Hi, .pb file is here: link text image for example: C:\fakepath\dalia_1_cropped_image.jpg)

code example:

import cv2

from keras.preprocessing.image import img_to_array

liveness_pb = r'.\pb\liveness_8_batch_1_epoch_test2.pb' 

modelCV = cv2.dnn.readNetFromTensorflow(liveness_pb)

face_cropped = cv2.imread('dalia_1_cropped_image.jpg')

face_resized = cv2.resize(face_cropped, (32, 32))

face = face_resized.astype("float") / 255.0

face = img_to_array(face)

face = np.expand_dims(face, axis=0)

modelCV_2.setInput(face)

out = modelCV_2.forward()  

print(out)

and error is:

OpenCV(4.0.1) C:\projects\opencv-python\opencv\modules\dnn\src\layers\permute_layer.cpp:173: error: (-215:Assertion failed) (int)_numAxes == inp0.d

Maxim Roshior gravatar imageMaxim Roshior ( 2019-04-10 10:07:32 -0500 )edit