Skip to content

Commit

Permalink
Add test for caffe.draw.draw_net()
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeyeager committed Mar 31, 2017
1 parent a2601ed commit 4650a36
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/caffe/test/test_draw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import unittest

from google import protobuf

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:
protobuf.text_format.Merge(infile.read(), net)
caffe.draw.draw_net(net, 'LR')

0 comments on commit 4650a36

Please sign in to comment.