Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error from cv2.dnn.readNetFromTensorflow Lambda layer

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()