Ask Your Question
0

Can't load caffe model with DummyData layer

asked 2018-09-14 10:35:18 -0600

feider_feisen gravatar image

updated 2018-09-18 04:17:15 -0600

Hi,

when I try to load a caffe model with OpenCV 3.4.3, I get the error:

what():  OpenCV(3.4.3) /home/schneider/libs/opencv-3.4.3/modules/dnn/src/dnn.cpp:412: error: (-2:Unspecified error) Can't create layer "DummyData1" of type "DummyData" in function 'getLayerInstance'*

It crashes in the line

cv::dnn::Net network = cv::dnn::readNetFromCaffe(modelTxt, modelBin);

The layer in the .prototxt file looks like this:

layer {
  name: "DummyData1"
  type: "DummyData"
  top: "DummyData1"
  dummy_data_param {
    shape {
      dim: 1
      dim: 32
      dim: 125
      dim: 100
    }
  }
}

It appears that the layer is missing in OpenCV. The caffe layer is described here on the Caffe webpage, but I am not sure how to implement this layer in OpenCV. Has it already been implemented somewhere? How can I solve this problem?

EDIT:

Here is the link to the full .prototxt

edit retag flag offensive close merge delete

Comments

1

can you add your prototxt here, so we can see, where an how it is used ?

berak gravatar imageberak ( 2018-09-18 03:18:54 -0600 )edit
1

It is done!

feider_feisen gravatar imagefeider_feisen ( 2018-09-18 04:17:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-17 01:45:19 -0600

dkurt gravatar image

@feider_feisen, If you able to change a .prototxt file you can replace these line to the following ones:

layer {
  type: "Input"
  name: "DummyData1"
  top: "DummyData1"
  input_param {
    shape {
      dim: 1
      dim: 32
      dim: 125
      dim: 100
    }
  }
}

or

input: "DummyData1"
input_dim: 1
input_dim: 32
input_dim: 125
input_dim: 100
edit flag offensive delete link more

Comments

Thank you, I tried both out. Unfortunately now I get the error:

what(): OpenCV(3.4.3) /home/schneider/libs/opencv-3.4.3/modules/dnn/src/dnn.cpp:2010: error: (-215:Assertion failed) inp.total() in function 'allocateLayers'

feider_feisen gravatar imagefeider_feisen ( 2018-09-17 02:14:24 -0600 )edit

@feider_feisen, please share some code snippet where you call setInput.

dkurt gravatar imagedkurt ( 2018-09-17 07:24:07 -0600 )edit

This is my whole code:

   
    std::string img_name = "/path/to/image.png";
    cv::String modelTxt = "keras/cmod.prototxt";
    cv::String modelBin = "keras/cmod.caffemodel";
    cv::dnn::Net network = cv::dnn::readNetFromCaffe(modelTxt, modelBin);
    cv::Mat img = cv::imread(img_name);
    resize(img, img, cv::Size(250, 200));
    cv::Mat blob;
    blob = cv::dnn::blobFromImage(img);
    network.setInput(blob);
    cv::Mat prob = network.forward();

It crashes with this error in network.forward();

feider_feisen gravatar imagefeider_feisen ( 2018-09-17 07:46:57 -0600 )edit
1

@dkurt, i don't think, the network (image) input layer is meant here.

it looks more like an internal data generator see e.g. here or here or here

berak gravatar imageberak ( 2018-09-18 03:18:13 -0600 )edit

@feider_feisen, please provide some ways to reproduce. We need a .prototxt file to know how to help you.

dkurt gravatar imagedkurt ( 2018-09-18 03:34:42 -0600 )edit

Ok, I have linked my .prototxt here

Thank you for your help so far!

feider_feisen gravatar imagefeider_feisen ( 2018-09-18 03:49:41 -0600 )edit

@feider_feisen, please try to replace this layer to layer with type: "Input" and set this blob manually by setInput(dummyBlob, "DummyData1") using some dummyBlob Mat with random values. Actual setInput replace to setInput(blob, "input_1").

dkurt gravatar imagedkurt ( 2018-09-18 03:59:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-14 10:35:18 -0600

Seen: 822 times

Last updated: Sep 18 '18