VIsualize network by using python

10,769 views
Skip to first unread message

Pan.H.BestSonny

unread,
Jan 11, 2015, 9:57:12 PM1/11/15
to caffe...@googlegroups.com
I want to visualize my network using python.But I do not know how to start it.I notice there is a draw.py in Python wrapper.
Anyone to give me a example.Thank you!

Bartosz Ludwiczuk

unread,
Jan 12, 2015, 5:06:19 AM1/12/15
to caffe...@googlegroups.com

Dinesh

unread,
Jan 13, 2015, 10:46:56 AM1/13/15
to caffe...@googlegroups.com
If by visualizing the network, you mean drawing the structure of the network, use:

$ caffe/python/draw_net.py <netprototxt_filename> <out_img_filename>

Prasanna Date

unread,
Jun 18, 2015, 12:56:55 PM6/18/15
to caffe...@googlegroups.com

I'm trying to draw my net in Caffe. The net is defined in `expt/expt.prototxt` and the desired image path is `expt/net.png`. When I run the command `./python/draw_net.py expt/expt.prototxt expt/net.png`, I get the following error:

    Couldn't import dot_parser, loading of dot files will not be possible.
    Drawing net to expt/net.png
    Traceback (most recent call last):
      File "./python/draw_net.py", line 44, in <module>
        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/pras/caffe/python/caffe/draw.py", line 165, in draw_net_to_file
        fid.write(draw_net(caffe_net, rankdir, ext))
      File "/home/pras/caffe/python/caffe/draw.py", line 156, in draw_net
        return get_pydot_graph(caffe_net, rankdir).create(format=ext)
      File "/home/pras/anaconda/lib/python2.7/site-packages/pydot.py", line 1727, in create
        'GraphViz\'s executables not found' )
    pydot.InvocationException: GraphViz's executables not found

I'm running Caffe on Ubuntu 14.04 in CPU mode using the Anaconda Python interface. Any ideas why this error might be occuring and how to go about correcting it?

Tharu

unread,
Jun 22, 2015, 11:27:52 AM6/22/15
to caffe...@googlegroups.com
Hi all,

I am also trying to draw net using draw_net.py. But it fails to draw net from imagenet prototext too( given in example folder).

Can anyone please help on it?
 
I did :

python draw_net.py <protext> <outfile>

Tharu

unread,
Jun 23, 2015, 12:38:34 PM6/23/15
to caffe...@googlegroups.com
Hi,

I am still not able to fix this problem. Has anyone fixed it?  Could someone help me please?>




On Monday, January 12, 2015 at 3:57:12 AM UTC+1, Pan.H.BestSonny wrote:

gokul krishnan

unread,
Jul 12, 2015, 10:32:02 AM7/12/15
to caffe...@googlegroups.com
Hi everyone!
I had the same problem when I installed pydot via pip
I removed it and installed it from the ubuntu repository "sudo apt-get install python-pydot"

Hope this helps!

KV

unread,
Jul 14, 2015, 12:42:24 PM7/14/15
to caffe...@googlegroups.com
It looks like the examples have been relocated (?) -- anyone know where they can be found now?

Amir Abdi

unread,
Dec 7, 2015, 8:51:19 PM12/7/15
to Caffe Users
I am also looking to find the sample code for visualization. Can't find it.

Eder Ruiz Maria

unread,
Jan 13, 2016, 3:12:24 PM1/13/16
to Caffe Users
You need install GraphViz

If you are using ubuntu: sudo apt-get install graphviz

Felipe Cicero

unread,
Apr 30, 2016, 2:02:33 AM4/30/16
to Caffe Users
I Found this version, the exemples directory of caffe has one copy as well...

Hossein Hasanpour

unread,
May 1, 2016, 1:34:26 AM5/1/16
to Caffe Users
the draw.py inside python directory is only used to give you an image file of your architecture so that you can see how your model is structures. 
if order to visualize intermediate layers, you would like to have a look at 00-classification.ipynb located at Caffe_Root/Examples. 

Jeremy Rutman

unread,
May 15, 2016, 11:27:56 AM5/15/16
to Caffe Users
i get an error like this
google.protobuf.text_format.ParseError: 1:1 : Message type "caffe.NetParameter" has no field named "net".

when I try drawing a net like this:
$ python python/draw_net.py models/bvlc_reference_caffenet/solver.prototxt out.bmp

Does anyone know why this would be happening? 

Kaushik Pavani

unread,
Aug 8, 2016, 7:02:35 AM8/8/16
to Caffe Users
Try passing train_val file instead of solver.prototxt

charles....@digitalbridge.eu

unread,
Aug 10, 2016, 5:41:34 AM8/10/16
to Caffe Users

Volodymyr Turchenko

unread,
Jun 9, 2017, 10:25:36 PM6/9/17
to Caffe Users, charles....@digitalbridge.eu
Hi guys, please help! who knows how to improve a quality of the images produced by draw_net.py? They are 96 dpi, I need 300 dpi. Please advice! Cheers,Vlad

середа, 10 серпня 2016 р. 05:41:34 UTC-4 користувач charles....@digitalbridge.eu написав:

Volodymyr Turchenko

unread,
Jun 9, 2017, 10:28:12 PM6/9/17
to Caffe Users
Hi Bartosz, do you know how to improve a quality of the images produced by draw_net.py? They are 96 dpi, I need 300 dpi. Please advice! Cheers,Vlad


понеділок, 12 січня 2015 р. 05:06:19 UTC-5 користувач Bartosz Ludwiczuk написав:

Volodymyr Turchenko

unread,
Jun 10, 2017, 1:00:50 PM6/10/17
to Caffe Users
Oh, I just figured out how to solve it, just play with a picture in Adobe Photoshop, that's it! Cheers, Vlad

пʼятниця, 9 червня 2017 р. 22:28:12 UTC-4 користувач Volodymyr Turchenko написав:

sri paul

unread,
May 14, 2018, 1:14:57 PM5/14/18
to Caffe Users
sudo apt-get install graphviz
sudo apt-get install python-pydot

/path to caffe-root/python/draw_net.py /path to caffe_root/examples/mnist/lenet_train_test.prototxt test.jpeg
Reply all
Reply to author
Forward
0 new messages