Caffe下利用drawnet畫網絡圖攻略

1.下載Windows版Caffe
解壓後,在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 <module>
import caffe.draw
File "D:\caffe\pycaffe\caffe\draw.py", line 22, in <module>
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 <module>
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


成功


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章