-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualizationModel.py
More file actions
27 lines (24 loc) · 914 Bytes
/
VisualizationModel.py
File metadata and controls
27 lines (24 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import tensorflow as tf
import os
from tensorflow.python.platform import gfile
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-model",help="Input model path",default="")
def main():
args = parser.parse_args()
model_path = args.model
if not os.path.exists(model_path) or not os.path.isfile(model_path):
print "Error model path!!!"
exit()
output_dir = "build"+os.sep+os.path.basename(model_path).split(".")[0]
with tf.Session() as sess:
model_filename =model_path
with gfile.FastGFile(model_filename, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def)
train_writer = tf.summary.FileWriter(output_dir)
train_writer.add_graph(sess.graph)
os.system("tensorboard --logdir "+output_dir)
if __name__=="__main__":
main()