Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to draw model: "AttributeError" #3698

Closed
DreSimpelo opened this issue Feb 21, 2016 · 12 comments
Closed

Unable to draw model: "AttributeError" #3698

DreSimpelo opened this issue Feb 21, 2016 · 12 comments

Comments

@DreSimpelo
Copy link

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'

@wk910930
Copy link
Contributor

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.

@DreSimpelo
Copy link
Author

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.

@Duffycola
Copy link

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

@jurastm
Copy link

jurastm commented Sep 30, 2016

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

@arthink
Copy link

arthink commented Nov 7, 2016

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

@Amandaynzhou
Copy link

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'

@clancyian
Copy link

clancyian commented Mar 2, 2017

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

@IvanTurgenev
Copy link

i got the same problem, no solution found

@clancyian
Copy link

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,

@raulqf
Copy link

raulqf commented Mar 27, 2017

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)

@sagarhukkire
Copy link

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

@shelhamer
Copy link
Member

Fixed in #5477 and #5487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests