Caffe: Unable to draw model: "AttributeError"

Created on 22 Feb 2016  路  12Comments  路  Source: BVLC/caffe

When I try to draw a model, I get this error:

AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'

I have libprotoc version 3.0.0

~:>>protoc --version
libprotoc 3.0.0

Python 2.7.11 |Anaconda 2.5.0 (64-bit)

More Details:

caffe:>> ./python/draw_net.py ./examples/cifar10/cifar10_quick_train_test.prototxt ./visualization.png
Drawing net to ./visualization.png
Traceback (most recent call last):
  File "./python/draw_net.py", line 45, in <module>
    main()
  File "./python/draw_net.py", line 41, in main
    caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
  File "/home/andre/caffe/python/caffe/draw.py", line 222, in draw_net_to_file
    fid.write(draw_net(caffe_net, rankdir, ext))
  File "/home/andre/caffe/python/caffe/draw.py", line 204, in draw_net
    return get_pydot_graph(caffe_net, rankdir).create(format=ext)
  File "/home/andre/caffe/python/caffe/draw.py", line 151, in get_pydot_graph
    node_label = get_layer_label(layer, rankdir)
  File "/home/andre/caffe/python/caffe/draw.py", line 94, in get_layer_label
    layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size._values) else 1,
AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'

Most helpful comment

Just ran into this myself on deconv-deep-vis-toolbox branch
I removed the "._values" on lines 94,96,98 in python/caffe/draw.py. Looks like it wants to get the length of the array.
Worked after that

All 12 comments

I'm not very sure, but caffe may not support Protocol Buffers 3x. Try Protocol Buffers 2.6.1. It works for me at least.

I tried a range of protocol buffer versions from 2.5 to 3.0.0b2. None seemed to do the trick. I ended up giving up, and doing a fresh OS install :P

Was able to get everything installed without problems. I did decide to use OpenCV 3.0 instead of 3.1, though I don't think that caused my problems.

Cheers, closing.

would be good to know which version ended up working for you for future reference

has someone solved this problem?
I still didn't find any solution that really works

Just ran into this myself on deconv-deep-vis-toolbox branch
I removed the "._values" on lines 94,96,98 in python/caffe/draw.py. Looks like it wants to get the length of the array.
Worked after that

I follow arthink's method but doesn't solve it.
details:
amanda@amanda-ThinkStation-P500-Invalid-entry-length-16-Fixed-up-to-11:~/caffe$ sudo python python/draw_net.py examples/mnist/lenet_train_test.prototxt netImage/lenet.png Drawing net to netImage/lenet.png Traceback (most recent call last): File "python/draw_net.py", line 58, in <module> main() File "python/draw_net.py", line 54, in main phase) File "/home/amanda/caffe/python/caffe/draw.py", line 244, in draw_net_to_file fid.write(draw_net(caffe_net, rankdir, ext, phase)) File "/home/amanda/caffe/python/caffe/draw.py", line 223, in draw_net return get_pydot_graph(caffe_net, rankdir, phase=phase).create(format=ext) File "/home/amanda/caffe/python/caffe/draw.py", line 167, in get_pydot_graph node_label = get_layer_label(layer, rankdir) File "/home/amanda/caffe/python/caffe/draw.py", line 94, in get_layer_label layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size._values) else 1, AttributeError: 'google.protobuf.pyext._message.RepeatedScalarConta' object has no attribute '_values'

Works for me if i hardcode a number of values by removing a few if else constructs in draw.py
draw_diff.txt
.

i got the same problem, no solution found

Hi Ivan,
Have you tried hardcoding the values to 0 and 1 in draw_net.py ?
e.g. Replace :
layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size._values) else 1,
with
1,

I've removed the _values from lines 94,96 & 98 of draw.py and the draw net was as expected.

Final code:

node_label = '"%s%s(%s)%skernel size: %d%sstride: %d%spad: %d"' %\ (layer.name, separator, layer.type, separator, layer.convolution_param.kernel_size[0] if len(layer.convolution_param.kernel_size) else 1, separator, layer.convolution_param.stride[0] if len(layer.convolution_param.stride) else 1, separator, layer.convolution_param.pad[0] if len(layer.convolution_param.pad) else 0)

@arthink thanks buddy you deserve medal..thanks for careful observation

Fixed in #5477 and #5487

Was this page helpful?
0 / 5 - 0 ratings