caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Unable to draw model: "AttributeError"

Open DreSimpelo opened this issue 10 years ago • 12 comments

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'

DreSimpelo avatar Feb 21 '16 23:02 DreSimpelo

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.

wk910930 avatar Feb 23 '16 03:02 wk910930

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.

DreSimpelo avatar Feb 23 '16 15:02 DreSimpelo

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

Duffycola avatar Jul 13 '16 11:07 Duffycola

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

jurastm avatar Sep 30 '16 12:09 jurastm

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

arthink avatar Nov 07 '16 06:11 arthink

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'

Amandaynzhou avatar Feb 20 '17 12:02 Amandaynzhou

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

clancyian avatar Mar 02 '17 09:03 clancyian

i got the same problem, no solution found

IvanTurgenev avatar Mar 09 '17 16:03 IvanTurgenev

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,

clancyian avatar Mar 09 '17 17:03 clancyian

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)

raulqf avatar Mar 27 '17 12:03 raulqf

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

sagarhukkire avatar Apr 04 '17 07:04 sagarhukkire

Fixed in #5477 and #5487

shelhamer avatar Apr 12 '17 00:04 shelhamer