Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a2aaebb
update IP to new node
daming-lu Apr 2, 2018
d9aec25
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 2, 2018
c8ff8a4
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 3, 2018
9996d42
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 4, 2018
f609af0
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 5, 2018
7a897fc
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 5, 2018
df70d96
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 6, 2018
da74c18
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 6, 2018
3922cd2
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 7, 2018
f274b78
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 9, 2018
1eb7a81
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
fdf7ab1
hardcoding styles to nodes and edges
daming-lu Apr 10, 2018
e719dfd
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
dba5bad
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 10, 2018
3cbf005
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 11, 2018
9526d1b
Merge remote-tracking branch 'upstream/develop' into develop
daming-lu Apr 11, 2018
c16eaa2
fix demo bug
daming-lu Apr 12, 2018
08c624f
Merge remote-tracking branch 'upstream/develop' into fix_graph_end2end
daming-lu Apr 12, 2018
732547c
fixing graph bug
daming-lu Apr 12, 2018
d957f3c
rename
daming-lu Apr 12, 2018
3055be6
lint for precommit
daming-lu Apr 12, 2018
fa6cfc4
fix python lint
daming-lu Apr 12, 2018
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions frontend/src/graph/ui/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as svgToPngDownloadHelper from './svgToPngDownloadHelper.js';
import * as d3 from 'd3';

import has from 'lodash/has';
import isArrayLike from 'lodash/isArrayLike';

export default {
props: {
Expand Down Expand Up @@ -74,9 +75,11 @@ export default {
if (has(graphData, 'input') === false) {
return;
}
let inputIdToIndex = {};
for (let i=0; i<graphData['input'].length; ++i) {
let curInputNode = graphData['input'][i];
let nodeKey = curInputNode['name'];
inputIdToIndex[nodeKey] = i;
g.setNode(
nodeKey,
{
Expand Down Expand Up @@ -144,14 +147,16 @@ export default {
nodeKeys.push(outputNodeKey);

// add edges from inputs to node and from node to output
for (let e=0; e<curOperatorNode['input'].length; ++e) {
// TODO(daming-lu): hard-coding style here to this polyline shows shadows.
g.setEdge(curOperatorNode['input'][e], nodeKey);
if (has(curOperatorNode, 'input') && isArrayLike(curOperatorNode['input'])) {
for (let e = 0; e < curOperatorNode['input'].length; ++e) {
g.setEdge(curOperatorNode['input'][e], nodeKey);
}
}
if (has(curOperatorNode, 'output') && isArrayLike(curOperatorNode['output'])) {
g.setEdge(nodeKey, curOperatorNode['output'][0], {
style: 'stroke: #333;stroke-width: 1.5px',
});
}

g.setEdge(nodeKey, curOperatorNode['output'][0], {
style: 'stroke: #333;stroke-width: 1.5px',
});
}

// TODO(daming-lu): add prettier styles to diff nodes
Expand All @@ -172,7 +177,7 @@ export default {
let opIndex = d.slice(7); // remove prefix "opNode_"
nodeInfo = graphData.node[opIndex];
} else if (nodeType === 'input') {
nodeInfo = graphData.input[d-1];
nodeInfo = graphData.input[inputIdToIndex[d]];
} else {
nodeInfo = 'output';
}
Expand Down
45 changes: 17 additions & 28 deletions visualdl/server/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os

from google.protobuf.json_format import MessageToJson
from PIL import Image

from . import graphviz_graph as gg
from . import onnx
Expand Down Expand Up @@ -328,21 +327,27 @@ def add_edges(json_obj):
cur_node = json_obj['node'][node_index]

# input edges
for source in cur_node['input']:
if 'input' in cur_node and len(cur_node['input']) > 0:
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
if 'output' in cur_node and len(cur_node['output']) > 0:
json_obj['edges'].append({
'source': source,
'target': 'node_' + str(node_index),
'source': 'node_' + str(node_index),
'target': cur_node['output'][0],
'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
return json_obj


Expand Down Expand Up @@ -483,23 +488,7 @@ def add_edge(self, source, target, label, **kwargs):

def draw_graph(model_pb_path, image_dir):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The function name doesn't apply anymore. Also the we no longer need image_dir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. This will also be renamed in the cleanup PR.

json_str = load_model(model_pb_path)
best_image = None
min_width = None
for i in range(10):
# randomly generate dot images and select the one with minimum width.
g = GraphPreviewGenerator(json_str)
dot_path = os.path.join(image_dir, "temp-%d.dot" % i)
image_path = os.path.join(image_dir, "temp-%d.jpg" % i)
g(dot_path)

try:
im = Image.open(image_path)
if min_width is None or im.size[0] < min_width:
min_width = im.size
best_image = image_path
except Exception:
pass
return best_image
return json_str


if __name__ == '__main__':
Expand Down
15 changes: 11 additions & 4 deletions visualdl/server/visualDL
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,18 @@ def individual_audio():

@app.route('/data/plugin/graphs/graph')
def graph():
# TODO(ChunweiYan) need to add a config for whether have graph.
if graph_image_path is None or not os.path.isfile(graph_image_path):
data = {'url': ''}
# TODO(daming-lu): rename variables because we switched from static graph generated by graphviz
# to d3/dagre drawn svg
if graph_image_path is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will we generate static image? We might be able to remove block

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Like the TODO mentioned, we need to rename and remove some stuff because we were using GraphViz previously. I will do it after the release

data = {
'data': graph_image_path,
}
else:
data = {'url': '/graphs/image'}
image_dir = os.path.join(args.logdir, "graphs")
Copy link
Collaborator

Choose a reason for hiding this comment

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

image_dir seems un-necessary now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. It will be removed in the code cleanup.

if not os.path.isdir(image_dir):
os.mkdir(image_dir)
json_str = vdl_graph.draw_graph(args.model_pb, image_dir)
data = {'data': json_str}
result = gen_result(0, "", data)
return Response(json.dumps(result), mimetype='application/json')

Expand Down