Google DeepDream: Message type “caffe.NetParameter” has no field named “input_shape”

262 views
Skip to first unread message

Dennis Thieme

unread,
Nov 17, 2015, 2:43:04 AM11/17/15
to Caffe Users

I want to start the Google DeepDream IPython Notebook fromhttps://github.com/google/deepdream.

I installed the Dependencies listed in the notebook (caffe and protobuf) and started the notebook with the anaconda distribution of python.


model_path = '/home/dennis/caffe/models/bvlc_googlenet/' # substitute your path here
net_fn   = model_path + 'deploy.prototxt'
param_fn = model_path + 'bvlc_googlenet.caffemodel'

# Patching model to be able to compute gradients.
# Note that you can also manually add "force_backward: true" line to "deploy.prototxt".
model = caffe.io.caffe_pb2.NetParameter()
text_format.Merge(open(net_fn).read(), model)
model.force_backward = True
open('tmp.prototxt', 'w').write(str(model))

net = caffe.Classifier('tmp.prototxt', param_fn,
                       mean = np.float32([104.0, 116.0, 122.0]), # ImageNet mean, training set dependent
                       channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB

# a couple of utility functions for converting to and from Caffe's input image layout
def preprocess(net, img):
    return np.float32(np.rollaxis(img, 2)[::-1]) - net.transformer.mean['data']
def deprocess(net, img):
    return np.dstack((img + net.transformer.mean['data'])[::-1])


When running this code cell an error is thrown:


ParseError: 3:1 : Message type "caffe.NetParameter" has no field named "input_shape".


Here is the complete Stack Trace:


---------------------------------------------------------------------------
ParseError                                Traceback (most recent call last)
<ipython-input-9-200e4a0e8ca1> in <module>()
      7 model = caffe.io.caffe_pb2.NetParameter()
      8 test = open(net_fn).read()
----> 9 text_format.Merge(test, model)
     10 model.force_backward = True
     11 open('tmp.prototxt', 'w').write(str(model))

/opt/anaconda/lib/python2.7/site-packages/google/protobuf/text_format.pyc in Merge(text, message)
    263     ParseError: On ASCII parsing problems.
    264   """
--> 265   return MergeLines(text.split('\n'), message)
    266 
    267 

/opt/anaconda/lib/python2.7/site-packages/google/protobuf/text_format.pyc in MergeLines(lines, message)
    296     ParseError: On ASCII parsing problems.
    297   """
--> 298   _ParseOrMerge(lines, message, True)
    299   return message
    300 

/opt/anaconda/lib/python2.7/site-packages/google/protobuf/text_format.pyc in _ParseOrMerge(lines, message, allow_multiple_scalars)
    227   tokenizer = _Tokenizer(lines)
    228   while not tokenizer.AtEnd():
--> 229     _MergeField(tokenizer, message, allow_multiple_scalars)
    230 
    231 

/opt/anaconda/lib/python2.7/site-packages/google/protobuf/text_format.pyc in _MergeField(tokenizer, message, allow_multiple_scalars)
    354       raise tokenizer.ParseErrorPreviousToken(
    355           'Message type "%s" has no field named "%s".' % (
--> 356               message_descriptor.full_name, name))
    357 
    358   if field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:

ParseError: 3:1 : Message type "caffe.NetParameter" has no field named "input_shape".


Don't really know how to fix this error. I Hope you guys can help me.

AP

unread,
Nov 18, 2015, 1:19:23 AM11/18/15
to Caffe Users

Can you try by changing this line ( model = caffe.io.caffe_pb2.NetParameter()) to model = caffe_pb2.NetParameter().

Reply all
Reply to author
Forward
0 new messages