1.下载Windows版Caffe
https://github.com/BVLC/caffe/tree/windows
解压后,在windows目录下发现Caffe 2013工程
工程为64位
2.编译通过后,将D:\caffe-windows\python下的draw_net和D:\caffe-windows\examples\mnist\lenet_train_test.prototxt复制到d:\test下
3. cmd下输入Python draw_net.py lenet_train_test.prototxt lenet.png
-----------------------------------------------------------------------------
D:\test>Python draw_net.py lenet_train_test.prototxt lenet.png
Traceback (most recent call last):
File "draw_net.py", line 9, in
import caffe.draw
File "D:\caffe\pycaffe\caffe\draw.py", line 22, in
import pydot
ImportError: No module named pydot
解决办法:
必须先安装 graphviz,再安装pydot
D:\test>pip install graphviz
Collecting graphviz
Downloading graphviz-0.4.10-py2.py3-none-any.whl
Installing collected packages: graphviz
Successfully installed graphviz-0.4.10
D:\test>pip install pydot
Collecting pydot
Downloading pydot-1.2.2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pyparsing>=2.1.4 in c:\python27\lib\site-packages (from pydot)
Installing collected packages: pydot
Running setup.py install for pydot ... done
Successfully installed pydot-1.2.2
------------------------------------------------------------------------
D:\test>Python draw_net.py lenet_train_test.prototxt lenet.png
Drawing net to lenet.png
Traceback (most recent call last):
File "draw_net.py", line 45, in
main()
File "draw_net.py", line 41, in main
caffe.draw.draw_net_to_file(net, args.output_image_file, args.rankdir)
File "D:\caffe\pycaffe\caffe\draw.py", line 222, in draw_net_to_file
fid.write(draw_net(caffe_net, rankdir, ext))
File "D:\caffe\pycaffe\caffe\draw.py", line 204, in draw_net
return get_pydot_graph(caffe_net, rankdir).create(format=ext)
File "C:\Python27\lib\site-packages\pydot.py", line 1876, in create
prog=prog))
Exception: "dot.exe" not found in path.
解决办法:
下载 http://www.graphviz.org/Download_windows.php windows下的
graphviz安装
Graphviz 2.30: The msi installer is again causing problems with the PATH variable. We hope to have this fixed shortly.
graphviz |
current stable release |
development snapshot |
Windows |
graphviz-2.38.msi graphviz-2.38.zip |
|
安装graphviz-2.38.msi, 选择for everyone 否则会出错;
在path中设置graphviz路径,否则pydot解析不出来, 如C:\Program Files (x86)\Graphviz2.38\bin
成功