Ask Your Question

dnn.forward() can't create layer

asked 2017-11-09 06:02:33 -0500

System information (version)

OpenCV => : 3.3.0 Operating System / Platform => :Windows 10 Compiler => : Python 3.6 Detailed description

When loading Caffe neural network model I get error:

error: C:\projects\opencv-python\opencv\modules\dnn\src\dnn.cpp:365: error: (-2) Can't create layer "data" of type "WindowData" in function cv::dnn::experimental_dnn_v1::LayerData::getLayerInstance

Model and prototxt files:

Steps to reproduce

import cv2
net = cv2.dnn.readNetFromCaffe(
frame = cv2.imread('frame.jpg', cv2.IMREAD_GRAYSCALE)
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)),0.007843, (300, 300), 127.5)
detections = net.forward()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-11-10 01:42:02 -0500

dkurt gravatar image

@Westerby, try to replace WindowData layer to the following values:

input: "data"
input_dim: 1
input_dim: 3
input_dim: 227
input_dim: 227

Also, remove the last Accuracy layer.

To achieve similar quality, you need to subtract the values stored at imagenet_mean.binaryproto from input images. Here is a serialized .npyarray:

However I don't know how to process crop to 227x227 because I have no text_file_accroding_to_window_data_layer_formatting.txt file and I can't compare Caffe and OpenCV implementations. Can you share it?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-11-09 06:02:33 -0500

Seen: 733 times

Last updated: Nov 10 '17