Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
404b0b41
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
404b0b41
编写于
1月 07, 2018
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
can work properly
上级
20f391d3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
107 addition
and
22 deletion
+107
-22
server/visualdl/graph.py
server/visualdl/graph.py
+103
-18
server/visualdl/visual_dl.py
server/visualdl/visual_dl.py
+4
-4
未找到文件。
server/visualdl/graph.py
浏览文件 @
404b0b41
...
...
@@ -68,7 +68,7 @@ def rename_model(model_json):
all_nodes
[
idx
][
'name'
]
=
new_name
def
add
_links
(
model_json
):
def
get
_links
(
model_json
):
links
=
[]
for
input
in
model_json
[
'input'
]:
...
...
@@ -76,18 +76,22 @@ def add_links(model_json):
for
node
in
model_json
[
'node'
]:
if
name
in
node
[
'input'
]:
links
.
append
({
'source'
:
name
,
"target"
:
node
[
'name'
],
"label"
:
name
})
"target"
:
node
[
'name'
]})
# links.append({'source': name,
# "target": node['name'],
# "label": name})
for
source_node
in
model_json
[
'node'
]:
for
output
in
source_node
[
'output'
]:
for
target_node
in
model_json
[
'node'
]:
if
output
in
target_node
[
'input'
]:
links
.
append
({
'source'
:
source_node
[
'name'
],
'target'
:
target_node
[
'name'
],
'label'
:
output
})
'target'
:
target_node
[
'name'
]})
# links.append({'source': source_node['name'],
# 'target': target_node['name'],
# 'label': output})
model_json
[
'links'
]
=
links
return
links
def
get_node_links
(
model_json
):
...
...
@@ -174,6 +178,18 @@ def add_level_to_node_links(node_links):
def
get_level_to_all
(
node_links
,
model_json
):
"""
level_to_nodes {level -> [node_1, node_2]}
output:
{
"35": {
"inputs": [
38,
39
],
"nodes": [
46
],
"outputs": []
}, {}
"""
level_to_nodes
=
dict
()
for
idx
in
node_links
:
...
...
@@ -249,11 +265,48 @@ def get_level_to_all(node_links, model_json):
init_level
(
level
)
level_to_all
[
level
][
'outputs'
]
=
level_to_outputs
[
level
]
debug_print
(
level_to_all
)
#
debug_print(level_to_all)
return
level_to_all
def
level_to_coordinate
(
level_to_all
):
default_x
=
100
x_step
=
100
default_y
=
10
y_step
=
100
node_to_coordinate
=
dict
()
input_to_coordinate
=
dict
()
output_to_coordinate
=
dict
()
def
get_coordinate
(
x_idx
,
y_idx
):
x
=
default_x
+
x_idx
*
x_step
y
=
default_y
+
y_idx
*
y_step
return
{
"x"
:
int
(
x
),
"y"
:
int
(
y
)}
for
level
in
level_to_all
:
nodes
=
level_to_all
[
level
][
'nodes'
]
inputs
=
level_to_all
[
level
][
'inputs'
]
outputs
=
level_to_all
[
level
][
'outputs'
]
x_idx
=
0
for
node_idx
in
nodes
:
node_to_coordinate
[
node_idx
]
=
get_coordinate
(
x_idx
,
level
)
x_idx
+=
1
for
in_idx
in
inputs
:
input_to_coordinate
[
in_idx
]
=
get_coordinate
(
x_idx
,
level
)
x_idx
+=
1
for
out_idx
in
outputs
:
output_to_coordinate
[
out_idx
]
=
get_coordinate
(
x_idx
,
level
)
x_idx
+=
1
# debug_print(node_to_coordinate)
# debug_print(input_to_coordinate)
# debug_print(output_to_coordinate)
return
node_to_coordinate
,
input_to_coordinate
,
output_to_coordinate
def
add_edges
(
json_obj
):
# TODO(daming-lu): should try to de-duplicate node's out-edge
# Currently it is counted twice: 1 as out-edge, 1 as in-edge
...
...
@@ -295,9 +348,9 @@ def transform_for_echars(model_json):
}
};
paraSymbolSize
=
[
95
,
45
]
;
paraSymbol
=
'rect'
;
opSymbolSize
=
[
50
,
50
]
;
paraSymbolSize
=
[
95
,
45
]
paraSymbol
=
'rect'
opSymbolSize
=
[
50
,
50
]
option
=
{
"title"
:
{
...
...
@@ -312,7 +365,7 @@ def transform_for_echars(model_json):
{
"type"
:
"graph"
,
"layout"
:
"none"
,
"symbolSize"
:
50
,
"symbolSize"
:
8
,
"roam"
:
True
,
"label"
:
{
"normal"
:
{
...
...
@@ -343,8 +396,42 @@ def transform_for_echars(model_json):
}
option
[
'title'
][
'text'
]
=
model_json
[
'name'
]
node_links
=
get_node_links
(
model_json
)
add_level_to_node_links
(
node_links
)
level_to_all
=
get_level_to_all
(
node_links
,
model_json
)
node_to_coordinate
,
input_to_coordinate
,
output_to_coordinate
=
level_to_coordinate
(
level_to_all
)
inputs
=
model_json
[
'input'
]
nodes
=
model_json
[
'node'
]
outputs
=
model_json
[
'output'
]
echars_data
=
list
()
for
in_idx
in
range
(
len
(
inputs
)):
input
=
inputs
[
in_idx
]
data
=
dict
()
data
[
'name'
]
=
input
[
'name'
]
data
[
'x'
]
=
input_to_coordinate
[
in_idx
][
'x'
]
data
[
'y'
]
=
input_to_coordinate
[
in_idx
][
'y'
]
echars_data
.
append
(
data
)
for
node_idx
in
range
(
len
(
nodes
)):
node
=
nodes
[
node_idx
]
data
=
dict
()
data
[
'name'
]
=
node
[
'name'
]
data
[
'x'
]
=
node_to_coordinate
[
node_idx
][
'x'
]
data
[
'y'
]
=
node_to_coordinate
[
node_idx
][
'y'
]
echars_data
.
append
(
data
)
for
out_idx
in
range
(
len
(
outputs
)):
output
=
outputs
[
out_idx
]
data
=
dict
()
data
[
'name'
]
=
output
[
'name'
]
data
[
'x'
]
=
output_to_coordinate
[
out_idx
][
'x'
]
data
[
'y'
]
=
output_to_coordinate
[
out_idx
][
'y'
]
echars_data
.
append
(
data
)
option
[
'series'
][
0
][
'data'
]
=
echars_data
option
[
'series'
][
0
][
'links'
]
=
get_links
(
model_json
)
return
option
...
...
@@ -360,12 +447,10 @@ def load_model(model_pb_path):
reorganize_inout
(
model_json
,
'input'
)
reorganize_inout
(
model_json
,
'output'
)
rename_model
(
model_json
)
add_links
(
model_json
)
debug_print
(
model_json
)
node_links
=
get_node_links
(
model_json
)
add_level_to_node_links
(
node_links
)
get_level_to_all
(
node_links
,
model_json
)
return
json
.
dumps
(
model_json
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
','
,
': '
))
# debug_print(model_json)
options
=
transform_for_echars
(
model_json
)
# debug_print(options)
return
json
.
dumps
(
options
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
','
,
': '
))
if
__name__
==
'__main__'
:
...
...
@@ -374,4 +459,4 @@ if __name__ == '__main__':
current_path
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]))
# json_str = load_model(current_path + "/mock/inception_v1_model.pb")
json_str
=
load_model
(
current_path
+
"/mock/squeezenet_model.pb"
)
#
print(json_str)
print
(
json_str
)
server/visualdl/visual_dl.py
浏览文件 @
404b0b41
...
...
@@ -7,7 +7,7 @@ from optparse import OptionParser
from
flask
import
(
Flask
,
Response
,
redirect
,
request
,
send_file
,
send_from_directory
)
import
graph
import
graph
as
vdl_graph
import
lib
import
storage
import
visualdl.mock.data
as
mock_data
...
...
@@ -169,9 +169,9 @@ def histogram():
@
app
.
route
(
'/data/plugin/graphs/graphs'
)
def
graph
():
# run = request.args.get('run')
# model_json
= graph.load_model(""
)
model_json_str
=
mock_data
.
graph_data
(
)
model_json
=
json
.
loads
(
model_json_str
)
# model_json
_str = mock_data.graph_data(
)
# model_json = json.loads(model_json_str
)
model_json
=
vdl_graph
.
load_model
(
server_path
+
"/mock/squeezenet_model.pb"
)
result
=
gen_result
(
0
,
""
,
model_json
)
return
Response
(
json
.
dumps
(
result
),
mimetype
=
'application/json'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录