Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added edges to graph. Also added script to download mock models #39

Merged
merged 7 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion server/visualdl/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ def reorganize_inout(json_obj, key):
json_obj[key][index] = var_new


def add_edges(json_obj):
json_obj['edges'] = []
label_incrementer = 0

for node_index in range(0, len(json_obj['node'])):
cur_node = json_obj['node'][node_index]

# input edges
for source in cur_node['input']:
json_obj['edges'].append({
'source': source,
'target': 'node_' + str(node_index),
'label': 'label_' + str(label_incrementer)
})
label_incrementer += 1

# output edge
json_obj['edges'].append({
'source': 'node_' + str(node_index),
'target': cur_node['output'][0],
'label': 'label_' + str(label_incrementer)
})
label_incrementer += 1


def load_model(model_pb_path):
model = onnx.load(model_pb_path)
graph = model.graph
Expand All @@ -38,12 +63,14 @@ def load_model(model_pb_path):
json_obj = json.loads(json_str)
reorganize_inout(json_obj, 'input')
reorganize_inout(json_obj, 'output')
add_edges(json_obj)
return json.dumps(json_obj, sort_keys=True, indent=4, separators=(',', ': '))


if __name__ == '__main__':
import os
import sys
current_path = os.path.abspath(os.path.dirname(sys.argv[0]))
json_str = load_model(current_path + "/mock/inception_v1.pb")
# json_str = load_model(current_path + "/mock/inception_v1.pb")
json_str = load_model(current_path + "/mock/squeezenet_model.pb")
print(json_str)
6 changes: 6 additions & 0 deletions server/visualdl/mock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Note
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add a download script

Squeezenet and Inception_v1 are onnx/models.

squeezenet has 53 inputs, 66 nodes and 1 output.

inception_v1 has 117 inputs, 143 nodes and 1 output.
Loading