Concatenate failing check for #axes?
Using OpenCV, I am trying to classify an image. The neural network I used to train it takes in an image and hand-crafted features and late fuses them at the fully-connected layers before classification. I know the image classification only pipeline works properly because I was successfully able to take a trained network and apply it to just images.
As a dummy example... this doesn't seem to run
Size size(n, n);
Mat1f imageBlobMat(size);
// Code to fill values for imageBlobMat here (preprocessing image)
Size sizeFeatures(20,1); // 20 hand-crafted features
Mat1f featBlobMat(sizeFeatures);
// Code to normalize these features here
dnn::Blob imageBlob = dnn::Blob(imageBlobMat);
net.setBlob(".image", imageBlob);
dnn::Blob featBlob = dnn::Blob(featBlobMat);
net.setBlob(".feat", featBlob);
net.forward();
dnn::Blob prob = net.getBlob("prob");
The prototxt file looks like below. I want to reiterate that I trained using the prototxt file and modified the top and bottom to create a deploy.prototxt so I know that these layers work together when to train a caffe model.
name: "NetworkName"
input: "image"
input_dim: 1
input_dim: 1
input_dim: n
input_dim: n
input: "feat"
input_dim: 1
input_dim: 1
input_dim: 1
input_dim: 20
...
Conv Layers on Image input
...
layer{
name: "flatten"
type: "Flatten"
bottom: "drop"
top: "flatten"
}
layer{
name: "concat"
type: "Concat"
bottom: "flatten"
bottom: "feat"
top: "concat"
concat_param{
axis: 1
}
}
I am getting this error:
OpenCV Error: Assertion failed (curShape.dims() == refShape.dims() && inputs[i]->type() == refType) in allocate, file /opt/opencv_contrib/modules/dnn/src/layers/concat_layer.cpp, line 69
terminate called after throwing an instance of 'cv::Exception'
what(): /opt/opencv_contrib/modules/dnn/src/layers/concat_layer.cpp:69: error: (-215) curShape.dims() == refShape.dims() && inputs[i]->type() == refType in function allocate
It seems related to the size of the inputs, so I've tried modifying the shape of featBlobMat to be 1x20 and 20x1, and changed the input_dims in all possible ways. [1 1 1 20], [1 1 20 1], [1 20], [20 1], and nothing seems to work. Any pointers?
EDIT: Accidentally posted something meant for the Caffe question board... Oops! Revised.
interesting question, but how is this related to opencv ?