forked from NVIDIA/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
, BVLC#5487 from BVLC/caffe Fix Python net drawing script Revert "Fix Python net drawing script" This reverts commit db6cf0a. Add test for caffe.draw.draw_net() Minor fix for net drawing script Add main() for draw_net unittest, fix import errors
- Loading branch information
1 parent
6d72336
commit c3771c5
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import unittest | ||
|
||
from google.protobuf import text_format | ||
|
||
import caffe.draw | ||
from caffe.proto import caffe_pb2 | ||
|
||
def getFilenames(): | ||
"""Yields files in the source tree which are Net prototxts.""" | ||
result = [] | ||
|
||
root_dir = os.path.abspath(os.path.join( | ||
os.path.dirname(__file__), '..', '..', '..')) | ||
assert os.path.exists(root_dir) | ||
|
||
for dirname in ('models', 'examples'): | ||
dirname = os.path.join(root_dir, dirname) | ||
assert os.path.exists(dirname) | ||
for cwd, _, filenames in os.walk(dirname): | ||
for filename in filenames: | ||
filename = os.path.join(cwd, filename) | ||
if filename.endswith('.prototxt') and 'solver' not in filename: | ||
yield os.path.join(dirname, filename) | ||
|
||
|
||
class TestDraw(unittest.TestCase): | ||
def test_draw_net(self): | ||
for filename in getFilenames(): | ||
net = caffe_pb2.NetParameter() | ||
with open(filename) as infile: | ||
text_format.Merge(infile.read(), net) | ||
caffe.draw.draw_net(net, 'LR') | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ if ! $WITH_PYTHON3 ; then | |
else | ||
# Python3 | ||
pip install --pre protobuf==3.0.0b3 | ||
pip install pydot | ||
fi |