Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
6ddd8049
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6ddd8049
编写于
12月 17, 2020
作者:
T
Tingquan Gao
提交者:
GitHub
12月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add "cpu_num_threads" and "enable_profile" (#494)
上级
c2aed7c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
6 deletion
+15
-6
deploy/hubserving/clas/params.py
deploy/hubserving/clas/params.py
+2
-0
tools/test_hubserving.py
tools/test_hubserving.py
+13
-6
未找到文件。
deploy/hubserving/clas/params.py
浏览文件 @
6ddd8049
...
@@ -33,6 +33,8 @@ def read_params():
...
@@ -33,6 +33,8 @@ def read_params():
cfg
.
gpu_mem
=
8000
cfg
.
gpu_mem
=
8000
cfg
.
use_fp16
=
False
cfg
.
use_fp16
=
False
cfg
.
use_tensorrt
=
False
cfg
.
use_tensorrt
=
False
cfg
.
cpu_num_threads
=
10
cfg
.
enable_profile
=
False
# params for preprocess
# params for preprocess
cfg
.
resize_short
=
256
cfg
.
resize_short
=
256
...
...
tools/test_hubserving.py
浏览文件 @
6ddd8049
...
@@ -57,19 +57,27 @@ def main(url, image_path, top_k=1):
...
@@ -57,19 +57,27 @@ def main(url, image_path, top_k=1):
all_acc
=
0.0
all_acc
=
0.0
for
image_file
in
image_file_list
:
for
image_file
in
image_file_list
:
file_str
=
image_file
.
split
(
'/'
)[
-
1
]
img
=
open
(
image_file
,
'rb'
).
read
()
img
=
open
(
image_file
,
'rb'
).
read
()
if
img
is
None
:
if
img
is
None
:
logger
.
info
(
"error in loading image:{}
"
.
format
(
image_file
))
logger
.
error
(
"Loading image:{} failed
"
.
format
(
image_file
))
continue
continue
data
=
{
'images'
:
[
cv2_to_base64
(
img
)],
'top_k'
:
top_k
}
data
=
{
'images'
:
[
cv2_to_base64
(
img
)],
'top_k'
:
top_k
}
starttime
=
time
.
time
()
starttime
=
time
.
time
()
r
=
requests
.
post
(
url
=
url
,
headers
=
headers
,
data
=
json
.
dumps
(
data
))
try
:
assert
r
.
status_code
==
200
,
"Request error, status_code: {}"
.
format
(
r
=
requests
.
post
(
url
=
url
,
headers
=
headers
,
data
=
json
.
dumps
(
data
))
r
.
status_code
)
r
.
raise_for_status
()
except
Exception
as
e
:
logger
.
error
(
"File:{}, {}"
.
format
(
file_str
,
e
))
continue
elapse
=
time
.
time
()
-
starttime
elapse
=
time
.
time
()
-
starttime
total_time
+=
elapse
total_time
+=
elapse
if
r
.
json
()[
'status'
]
!=
'0'
:
logger
.
error
(
"File:{}, The parameters returned by the server are: {}"
.
format
(
file_str
,
r
.
json
()[
'msg'
]))
continue
res
=
r
.
json
()[
"results"
][
0
]
res
=
r
.
json
()[
"results"
][
0
]
classes
=
res
[
0
]
classes
=
res
[
0
]
scores
=
res
[
1
]
scores
=
res
[
1
]
...
@@ -79,7 +87,6 @@ def main(url, image_path, top_k=1):
...
@@ -79,7 +87,6 @@ def main(url, image_path, top_k=1):
scores
=
map
(
lambda
x
:
round
(
x
,
5
),
scores
)
scores
=
map
(
lambda
x
:
round
(
x
,
5
),
scores
)
results
=
dict
(
zip
(
classes
,
scores
))
results
=
dict
(
zip
(
classes
,
scores
))
file_str
=
image_file
.
split
(
'/'
)[
-
1
]
message
=
"No.{}, File:{}, The top-{} result(s):{}, Time cost:{:.3f}"
.
format
(
message
=
"No.{}, File:{}, The top-{} result(s):{}, Time cost:{:.3f}"
.
format
(
cnt
,
file_str
,
top_k
,
results
,
elapse
)
cnt
,
file_str
,
top_k
,
results
,
elapse
)
logger
.
info
(
message
)
logger
.
info
(
message
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录