0

When using ipython:

   net = caffe.Classifier(MODEL_FILE, PRETRAINED)

I got an exception when I use the original train.prototxt as the pretrained_file(PRETRAINED)

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-5-af51e3c78bed> in <module>()
      2 plt.rcParams['image.interpolation'] = 'nearest'
      3 plt.rcParams['image.cmap'] = 'gray'
----> 4 net = caffe.Classifier(MODEL_FILE, PRETRAINED)
/home/xiayu/work/caffe/caffe-master/python/caffe/classifier.pyc in 

__init__(self, model_file, pretrained_file, image_dims, mean, input_scale, raw_scale, channel_swap)
     27 
     28         # configure pre-processing
---> 29         in_ = self.inputs[0]
     30         self.transformer = caffe.io.Transformer(
     31             {in_: self.blobs[in_].data.shape})

IndexError: list index out of range

I have no idea why in_ = self.inputs[0] the index 0 is out of range, Here I know a specified deploy.prototxt may work, but I don't know how.

really hope some can answer my question!

Shai
  • 111,146
  • 38
  • 238
  • 371
C.Tony
  • 1
  • 2

1 Answers1

2

You get this error because your train_val.prototxt has no "external" inputs: There are no "bottom"s that are expected by the net and not provided by the net.
This is because the train_val.prototxt has a specialized data layers that take care of the input (usually using pre computed datasets like lmdb/leveldb/hdf5 etc.).
If you look closely at your deploy.prototxt you'll notice it has no input layer, instead it has a declaration:

net: "some name"
input: "data"
input_shape {
  dim: 10
  dim: 3
  dim: 224
  dim: 224
}

This statement declares an "external" input, that is the resulting net will expect an input of name "data" with shape (10,3,224,224).
Your train_val.prototxt has no such declaration.

Shai
  • 111,146
  • 38
  • 238
  • 371