Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
7b83d4dd
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
285
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7b83d4dd
编写于
11月 29, 2019
作者:
S
sjtubinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix python infer colormap bug
上级
74babb5d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
8 deletion
+16
-8
deploy/python/infer.py
deploy/python/infer.py
+16
-8
未找到文件。
deploy/python/infer.py
浏览文件 @
7b83d4dd
...
@@ -33,12 +33,19 @@ gflags.DEFINE_boolean("use_pr", default=False, help="Use optimized model")
...
@@ -33,12 +33,19 @@ gflags.DEFINE_boolean("use_pr", default=False, help="Use optimized model")
gflags
.
DEFINE_string
(
"trt_mode"
,
default
=
""
,
help
=
"Use optimized model"
)
gflags
.
DEFINE_string
(
"trt_mode"
,
default
=
""
,
help
=
"Use optimized model"
)
gflags
.
FLAGS
=
gflags
.
FLAGS
gflags
.
FLAGS
=
gflags
.
FLAGS
# ColorMap for visualization
# Generate ColorMap for visualization
color_map
=
[[
128
,
64
,
128
],
[
244
,
35
,
231
],
[
69
,
69
,
69
],
[
102
,
102
,
156
],
def
generate_colormap
(
num_classes
):
[
190
,
153
,
153
],
[
153
,
153
,
153
],
[
250
,
170
,
29
],
[
219
,
219
,
0
],
color_map
=
num_classes
*
[
0
,
0
,
0
]
[
106
,
142
,
35
],
[
152
,
250
,
152
],
[
69
,
129
,
180
],
[
219
,
19
,
60
],
for
i
in
range
(
0
,
num_classes
):
[
255
,
0
,
0
],
[
0
,
0
,
142
],
[
0
,
0
,
69
],
[
0
,
60
,
100
],
[
0
,
79
,
100
],
j
=
0
[
0
,
0
,
230
],
[
119
,
10
,
32
]]
lab
=
i
while
lab
:
color_map
[
i
*
3
]
|=
(((
lab
>>
0
)
&
1
)
<<
(
7
-
j
))
color_map
[
i
*
3
+
1
]
|=
(((
lab
>>
1
)
&
1
)
<<
(
7
-
j
))
color_map
[
i
*
3
+
2
]
|=
(((
lab
>>
2
)
&
1
)
<<
(
7
-
j
))
j
+=
1
lab
>>=
3
return
color_map
# Paddle-TRT Precision Map
# Paddle-TRT Precision Map
trt_precision_map
=
{
trt_precision_map
=
{
...
@@ -202,6 +209,7 @@ class Predictor:
...
@@ -202,6 +209,7 @@ class Predictor:
score_png
=
mask_png
[:,
:,
np
.
newaxis
]
score_png
=
mask_png
[:,
:,
np
.
newaxis
]
score_png
=
np
.
concatenate
([
score_png
]
*
3
,
axis
=
2
)
score_png
=
np
.
concatenate
([
score_png
]
*
3
,
axis
=
2
)
# visualization score png
# visualization score png
color_map
=
generate_colormap
(
self
.
config
.
class_num
)
for
i
in
range
(
score_png
.
shape
[
0
]):
for
i
in
range
(
score_png
.
shape
[
0
]):
for
j
in
range
(
score_png
.
shape
[
1
]):
for
j
in
range
(
score_png
.
shape
[
1
]):
score_png
[
i
,
j
]
=
color_map
[
score_png
[
i
,
j
,
0
]]
score_png
[
i
,
j
]
=
color_map
[
score_png
[
i
,
j
,
0
]]
...
@@ -247,12 +255,12 @@ class Predictor:
...
@@ -247,12 +255,12 @@ class Predictor:
infer_start
=
time
.
time
()
infer_start
=
time
.
time
()
output_data
=
self
.
predictor
.
run
(
input_data
)[
0
]
output_data
=
self
.
predictor
.
run
(
input_data
)[
0
]
infer_end
=
time
.
time
()
infer_end
=
time
.
time
()
reader_time
+=
(
reader_end
-
reader_start
)
infer_time
+=
(
infer_end
-
infer_start
)
output_data
=
output_data
.
as_ndarray
()
output_data
=
output_data
.
as_ndarray
()
post_start
=
time
.
time
()
post_start
=
time
.
time
()
self
.
output_result
(
img_datas
,
output_data
,
gflags
.
FLAGS
.
use_pr
)
self
.
output_result
(
img_datas
,
output_data
,
gflags
.
FLAGS
.
use_pr
)
post_end
=
time
.
time
()
post_end
=
time
.
time
()
reader_time
+=
(
reader_end
-
reader_start
)
infer_time
+=
(
infer_end
-
infer_start
)
post_time
+=
(
post_end
-
post_start
)
post_time
+=
(
post_end
-
post_start
)
# finishing process all images
# finishing process all images
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录