4

I found the draw_net_to_file method in draw.py and want to use it to understand the Caffe network I was given to work with better.

The problem is that the following code

import caffe
from caffe.draw import draw_net_to_file
import numpy as np

weights = 'reference_model/caffe_reference_imagenet_model.weights'
means = 'reference_model/ilsvrc_2012_mean_reshaped.npy'
model = 'reference_model/imagenet_model_deploy.prototxt'

npmeans = np.load(means)

cls = caffe.Classifier(
    model,
    weights,
    mean=npmeans,
    image_dims=(256, 256),
    channel_swap=(2,1,0),
    raw_scale=(255),
)

draw_net_to_file(cls, "drawn_net.png");
print "DONE"

fails with the following error

/caffe/python/caffe/draw.pyc in get_pydot_graph(caffe_net, rankdir, label_edges)
--> 105   pydot_graph = pydot.Dot(caffe_net.name, graph_type='digraph', rankdir=rankdir)
AttributeError: 'Classifier' object has no attribute 'name'

Upon closer investigation, the Classifier object really does not expose many methods of the underlying Net object, such as name. How do I instantiate a correctly working Net instance for this case?

I'm using Caffe built from revision 737ea5e936821b5c69f9c3952d72693ae5843370.

1 Answer 1

3

Take a look at the script draw_net.py where you can see an example of how to use the functions of draw.py. The net argument is not exactly the same as the caffe.Net object but rather a parsed prototxt:

from google.protobuf import text_format
import caffe.draw
from caffe.proto import caffe_pb2

net = caffe_pb2.NetParameter()
text_format.Merge(open(args.input_net_proto_file).read(), net)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.