Ask Your Question
0

When loading caffe VGG-16 I get: error: (-215) (idx == -1 && size() == 1) || (idx >= 0 && idx < size()) in function get

asked 2018-03-26 09:28:35 -0600

Flipajs gravatar image

Hey guys,

First of all, I want to thank authors of DNN module I think it is great even though the process of running own networks is not well documented yet.

I am trying to load VGG-16_3C4x from model zoo - model. I've changed .prototxt file according to this tutorial. Changed .prototx

This is the error:

OpenCV(3.4.1) Error: Assertion failed ((idx == -1 && size() == 1) || (idx >= 0 && idx < size())) in get, file /tmp/opencv-20180307-60086-ryy1b3/opencv-3.4.1/modules/dnn/include/opencv2/dnn/dnn.inl.hpp, line 88 Traceback (most recent call last): File "run_caffe.py", line 35, in <module> result = net.forward() cv2.error: OpenCV(3.4.1) /tmp/opencv-20180307-60086-ryy1b3/opencv-3.4.1/modules/dnn/include/opencv2/dnn/dnn.inl.hpp:88: error: (-215) (idx == -1 && size() == 1) || (idx >= 0 && idx < size()) in function get

Here is the python code I use for loading.

Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2018-03-26 09:57:07 -0600

dkurt gravatar image

@Flipajs, duplication of pad and kernel_size parameters looks confusing but they are correct.

layer {
  name: "conv1_2_H"
  type: "Convolution"
  bottom: "conv1_2_V"
  top: "conv1_2_H"
  param {
    lr_mult: 1.0
    decay_mult: 1.0
  }
  convolution_param {
    num_output: 22
    bias_term: true
    pad: 0
    pad: 1
    kernel_size: 1
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "msra"
    }
  }
}

from caffe.proto:

  // Pad, kernel size, and stride are all given as a single value for equal
  // dimensions in all spatial dimensions, or once per spatial dimension.

There are pad_h and pad_w with kernel_h and kernel_w to define paddings and kernel sizes correspondingly for each dimension. So you can replace an every duplication to corresponding *_h and *_w parameters because OpenCV cannot manage it for now.

edit flag offensive delete link more

Comments

1

Thank you for your reply! I've changed it and it is working now. Adding code sample for those reading it in future:

layer {
  name: "relu1_1"
  type: "ReLU"
  bottom: "conv1_1"
  top: "conv1_1"
}
layer {
  name: "conv1_2_V"
  type: "Convolution"
  bottom: "conv1_1"
  top: "conv1_2_V"
  convolution_param {
    num_output: 22
    pad_h: 1
    pad_w: 0
    kernel_h: 3
    kernel_w: 1
    stride: 1
  }
}
Flipajs gravatar imageFlipajs ( 2018-03-26 11:26:29 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-03-26 09:28:35 -0600

Seen: 398 times

Last updated: Mar 26 '18