我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用caffe.draw()。
def draw_network(model, image_path): """ Draw a network and save the graph in the specified image path Args: model (str): path to the prototxt file (model definition) image_path (str): path where to save the image """ net = caffe_pb2.NetParameter() text_format.Merge(open(model).read(), net) caffe.draw.draw_net_to_file(net, image_path, 'BT') # In[ ]:
def printNetwork(prototxt_filename, caffemodel_filename): ''' Draw the CNN architecture as you want, actually, it may not work property ''' _net = caffe.proto.caffe_pb2.NetParameter() f = open(prototxt_filename) google.protobuf.text_format.Merge(f.read(), _net) caffe.draw.draw_net_to_file(_net, prototxt_filename + '.png' ) print('Draw CNN finished!')
def draw_net(net_proto_file, out_img_file, style = 'TB'): """ draw cnn network into image. IN: net_proto_file net definition file IN: style 'TB' for top-> bottom, 'LR' for lelf->right OUT: out_img_file output image """ net = caffe_pb2.NetParameter() text_format.Merge(open(net_proto_file).read(), net) if not net.name: net.name = 'cnn_net' print('\nDrawing net to %s' % out_img_file) caffe.draw.draw_net_to_file(net, out_img_file, style)