Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
06583b18
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 2 年 前同步成功
通知
89
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看板
未验证
提交
06583b18
编写于
1月 14, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
1月 14, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
graph apply new color theme (#135)
上级
42c327c4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
35 deletion
+35
-35
visualdl/server/graph.py
visualdl/server/graph.py
+20
-22
visualdl/server/graphviz_graph.py
visualdl/server/graphviz_graph.py
+15
-13
未找到文件。
visualdl/server/graph.py
浏览文件 @
06583b18
...
...
@@ -350,16 +350,16 @@ def load_model(model_pb_path):
class
GraphPreviewGenerator
(
object
):
'''
Generate a graph image for ONNX proto.
'''
def
__init__
(
self
,
model_json
):
#self.model = json.loads(model_json)
self
.
model
=
model_json
# init graphviz graph
self
.
graph
=
gg
.
Graph
(
self
.
model
[
'name'
],
layout
=
"dot"
,
#resolution=200,
concentrate
=
"true"
,
# rankdir="LR"
rankdir
=
"TB"
,
)
...
...
@@ -367,7 +367,7 @@ class GraphPreviewGenerator(object):
self
.
param_rank
=
self
.
graph
.
rank_group
(
'same'
,
1
)
self
.
arg_rank
=
self
.
graph
.
rank_group
(
'same'
,
0
)
def
__call__
(
self
,
path
=
'temp.dot'
):
def
__call__
(
self
,
path
=
'temp.dot'
,
show
=
False
):
self
.
nodes
=
{}
self
.
params
=
set
()
self
.
ops
=
set
()
...
...
@@ -375,14 +375,12 @@ class GraphPreviewGenerator(object):
for
item
in
self
.
model
[
'input'
]
+
self
.
model
[
'output'
]:
node
=
self
.
add_param
(
**
item
)
print
'name'
,
item
[
'name'
]
self
.
nodes
[
item
[
'name'
]]
=
node
self
.
params
.
add
(
item
[
'name'
])
for
id
,
item
in
enumerate
(
self
.
model
[
'node'
]):
node
=
self
.
add_op
(
**
item
)
name
=
"node_"
+
str
(
id
)
print
'name'
,
name
self
.
nodes
[
name
]
=
node
self
.
ops
.
add
(
name
)
...
...
@@ -403,15 +401,20 @@ class GraphPreviewGenerator(object):
else
:
edge
=
self
.
add_edge
(
style
=
"bold"
,
color
=
"#aaaaaa"
,
**
item
)
self
.
graph
.
display
(
path
)
if
not
show
:
self
.
graph
.
display
(
path
)
else
:
self
.
graph
.
show
(
path
)
def
add_param
(
self
,
name
,
data_type
,
shape
):
label
=
'
\n
'
.
join
([
'<<table cellpadding="5">'
,
' <tr>'
,
' <td bgcolor="#eeeeee">'
,
' <td bgcolor="#2b787e">'
,
' <b>'
,
name
,
' </td>'
' </b>'
,
' </td>'
,
' </tr>'
,
' <tr>'
,
' <td>'
,
...
...
@@ -429,23 +432,21 @@ class GraphPreviewGenerator(object):
label
,
prefix
=
"param"
,
shape
=
"none"
,
# rank=self.param_rank,
style
=
"rounded,filled,bold"
,
width
=
"1.3"
,
#color="#ffa0a0
",
color
=
"#8cc7
ff"
,
color
=
"#148b97
"
,
fontcolor
=
"#ffff
ff"
,
fontname
=
"Arial"
)
def
add_op
(
self
,
opType
,
**
kwargs
):
return
self
.
graph
.
node
(
gg
.
crepr
(
opType
),
# rank=self.op_rank,
"<<B>%s</B>>"
%
opType
,
prefix
=
"op"
,
shape
=
"box"
,
style
=
"rounded, filled, bold"
,
fillcolor
=
"#8cc7cd"
,
#fillcolor="#8cc7ff",
color
=
"#303A3A"
,
fontname
=
"Arial"
,
fontcolor
=
"#ffffff"
,
width
=
"1.3"
,
height
=
"0.84"
,
)
...
...
@@ -454,11 +455,11 @@ class GraphPreviewGenerator(object):
return
self
.
graph
.
node
(
gg
.
crepr
(
name
),
prefix
=
"arg"
,
# rank=self.arg_rank,
shape
=
"box"
,
style
=
"rounded,filled,bold"
,
fontname
=
"Arial"
,
color
=
"grey"
)
fontcolor
=
"#999999"
,
color
=
"#dddddd"
)
def
add_edge
(
self
,
source
,
target
,
label
,
**
kwargs
):
source
=
self
.
nodes
[
source
]
...
...
@@ -498,7 +499,4 @@ if __name__ == '__main__':
assert
json_str
g
=
GraphPreviewGenerator
(
json_str
)
g
(
'./temp.dot'
)
# for i in range(10):
# g = GraphPreviewGenerator(json_str)
# g('./temp-%d.dot' % i)
g
(
'./temp.dot'
,
show
=
False
)
visualdl/server/graphviz_graph.py
浏览文件 @
06583b18
...
...
@@ -28,14 +28,9 @@ class Rank(object):
if
not
self
.
nodes
:
return
''
# repr = []
# for node in self.nodes:
# repr.append(str(node))
return
'{'
+
'rank={};'
.
format
(
self
.
kind
)
+
\
','
.
join
([
node
.
name
for
node
in
self
.
nodes
])
+
'}'
# return '\n'.join(repr)
# the python package graphviz is too poor.
class
Graph
(
object
):
...
...
@@ -78,14 +73,21 @@ class Graph(object):
file
.
write
(
self
.
__str__
())
image_path
=
dot_path
[:
-
3
]
+
"jpg"
cmd
=
[
"dot"
,
"-Tjpg"
,
dot_path
,
"-o"
,
image_path
]
# cmd = "./preview.sh \"%s\"" % cmd
print
'cmd'
,
cmd
# subprocess.call(cmd, shell=True)
subprocess
.
Popen
(
cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
# os.system(' '.join(cmd))
# assert os.path.isfile(image_path), "no image generated"
subprocess
.
Popen
(
cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
return
image_path
def
show
(
self
,
dot_path
):
image
=
self
.
display
(
dot_path
)
cmd
=
[
"feh"
,
image
]
subprocess
.
Popen
(
cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
def
_rank_repr
(
self
):
ranks
=
sorted
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录