Error from cv2.dnn.readNetFromTensorflow Lambda layer

asked 2020-10-07 16:43:32 -0600

alecda gravatar image

I am encountering the following error when I try to make the forward pass from my inputted network:

error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:562: error: (-2:Unspecified error) Can't create layer "lambda_4/truediv" of type "RealDiv" in function 'cv::dnn::dnn4_v20191202::LayerData::getLayerInstance'

I have no issues reading the model, the code I am calling is the following that produces this error: (are Lambda layers a problem?)

import cv2
inputNet=cv2.dnn.readNetFromTensorflow("tf_model.pb")
img=cv2.imread(img_path)
img.shape
tensorflowNet.setInput(cv2.dnn.blobFromImage(img, size=(368, 368), swapRB=True, crop=False))
inputNet.setInput(cv2.dnn.blobFromImage(img, size=(368, 368), swapRB=True, crop=False))
networkOutput=inputNet.forward()
edit retag flag offensive close merge delete

Comments

btw, it is a tf.realdiv layer, "lambda" is only the name

is this running on colab ?

added 5 month ago, your 4.2.0 install might not have it. try to update

berak gravatar imageberak ( 2020-10-08 03:37:09 -0600 )edit

@berak will do, It is a lambda layer just performing image centering so img/255-.5

alecda gravatar imagealecda ( 2020-10-08 19:23:48 -0600 )edit