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

Draw Net Problem #1709

Closed
BestSonny opened this issue Jan 12, 2015 · 11 comments
Closed

Draw Net Problem #1709

BestSonny opened this issue Jan 12, 2015 · 11 comments

Comments

@BestSonny
Copy link

I try to visualize the network.But I get the errors.

AttributeError: type object 'LayerParameter' has no attribute 'LayerType'

I check the caffe caffe_pb2.py and get this:

_LAYERPARAMETER_LAYERTYPE = descriptor.EnumDescriptor(
name='LayerType',
full_name='caffe.LayerParameter.LayerType',
filename=None,
file=DESCRIPTOR,

Below is my use case:

import caffe
from caffe import draw
from caffe.proto import caffe_pb2

enddef

net = caffe_pb2.NetParameter()
with open('model/_iter_500000.caffemodel','rb') as f:
net.ParseFromString(f.read())
print net.name
draw.draw_net_to_file(net,'network.png')

@shelhamer
Copy link
Member

Do ./python/draw_net.py net.prototxt visualization.png. Please ask usage questions on the caffe-users mailing list.

@jsupancic
Copy link
Contributor

Hi,

This is a real bug (on the dev branch at least) and should be corrected. The problem is that you updated the layers protobuf format without updating draw_net.py

I've uploaded a patch here:
http://www.ics.uci.edu/~jsupanci/draw.patch

Best,
James Supancic III
PhD Candidate - University of California, Irvine

@shelhamer
Copy link
Member

@jsupancic can you send a PR to dev with the fix? This was broken by #1694. Thanks.

jsupancic added a commit to jsupancic/caffe-1 that referenced this issue Feb 12, 2015
Introduced by  Layer type is a string BVLC#1694
@jsupancic
Copy link
Contributor

@shelhamer I've sent a PR to Dev with the fix (#1860)

Best,
James

shelhamer pushed a commit that referenced this issue Feb 16, 2015
Introduced by  Layer type is a string #1694
@jsupancic
Copy link
Contributor

jsupancic commented Mar 17, 2015 via email

@anastasiadk
Copy link

Dear James @jsupancic and Evan @shelhamer ,

I downloaded and compiled the latest versions of both master and dev branches, but I still get the error
AttributeError: type object 'PoolingParameter' has no attribute 'PoolMethod'

I run the command (from Caffe installation directory)
./python/draw_net.py ./examples/cifar10/cifar10_quick_train_test.prototxt ./visualization.png

Do you have any idea why this may happen?

Thank you in advance,
Anastasia

@jsupancic
Copy link
Contributor

Dear Anastasia @nastyad ,

I cannot reproduce your problem. When I
(1) cloned a clean copy of caffe
(2) mkdir build, cd build, make -j16, cd ..
(3) ./python/draw_net.py ./examples/cifar10/cifar10_quick_train_test.prototxt ./visualization.png
no errors occur.

My guess is that something is wrong with the Python implementation of the caffe protobufs, maybe due to some version incompatibility? Could you post your caffe_pb2.py somewhere?

Best,
James

@anastasiadk
Copy link

Dear James @jsupancic,

I put the file here: http://www.cs.technion.ac.il/~nastyad/caffe_pb2.py

Thanks,
Anastasia

@b2220333
Copy link

Hello, I try to git pull to the latest caffe code ,and make all; make pycaffe;
After that I still have the same problem:
sam@sam:/code/download/CNN/caffe/caffe$ ./python/draw_net.py models/bvlc_reference_caffenet/deploy.prototxt ./abc.png
Drawing net to ./abc.png
Traceback (most recent call last):
File "./python/draw_net.py", line 44, in
main()
File "./python/draw_net.py", line 40, in main
caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
File "/home/sam/code/download/CNN/caffe/caffe/python/caffe/draw.py", line 172, in draw_net_to_file
fid.write(draw_net(caffe_net, rankdir, ext))
File "/home/sam/code/download/CNN/caffe/caffe/python/caffe/draw.py", line 162, in draw_net
return get_pydot_graph(caffe_net, rankdir).create(format=ext)
File "/home/sam/code/download/CNN/caffe/caffe/python/caffe/draw.py", line 115, in get_pydot_graph
node_label = determine_node_label_by_layertype(layer, layertype, rankdir)
File "/home/sam/code/download/CNN/caffe/caffe/python/caffe/draw.py", line 78, in determine_node_label_by_layertype
pooling_types_dict = get_pooling_types_dict()
File "/home/sam/code/download/CNN/caffe/caffe/python/caffe/draw.py", line 28, in get_pooling_types_dict
desc = caffe_pb2.PoolingParameter.PoolMethod.DESCRIPTOR
AttributeError: type object 'PoolingParameter' has no attribute 'PoolMethod'
sam@sam:
/code/download/CNN/caffe/caffe$

How to fix it?
Thank you~

@vodp
Copy link

vodp commented Jul 31, 2015

Try to build the latest protobuf, install it in /usr, compile python wrapper too. And re-build Caffe again.

@antran89
Copy link
Contributor

antran89 commented Oct 2, 2015

@VPlatoon Hi, do you solve the problem by installing the latest protobuf?
I met this problem when trying to visualize the network.

tranlaman@uCom:~/BLVC-caffe/examples$ ../python/draw_net.py /home/tranlaman/BLVC-caffe/models/bvlc_reference_caffenet/train_val.prototxt bvlc_reference_caffenet.jpg
Drawing net to bvlc_reference_caffenet.jpg
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/tranlaman/BLVC-caffe/python/caffe/draw.py", line 213, in draw_net_to_file
    fid.write(draw_net(caffe_net, rankdir, ext))
  File "/home/tranlaman/BLVC-caffe/python/caffe/draw.py", line 195, in draw_net
    return get_pydot_graph(caffe_net, rankdir).create(format=ext)
  File "/home/tranlaman/BLVC-caffe/python/caffe/draw.py", line 142, in get_pydot_graph
    node_label = get_layer_label(layer, rankdir)
  File "/home/tranlaman/BLVC-caffe/python/caffe/draw.py", line 89, in get_layer_label
    layer.convolution_param.pad)
TypeError: %d format: a number is required, not RepeatedScalarFieldContainer

Thank you.

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

7 participants