Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
68d17711
M
models
项目概览
PaddlePaddle
/
models
大约 2 年 前同步成功
通知
232
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
68d17711
编写于
12月 25, 2019
作者:
R
ruri
提交者:
GitHub
12月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs in image classification infer (#4125)
上级
7634fe7e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
2 deletion
+6
-2
PaddleCV/image_classification/README.md
PaddleCV/image_classification/README.md
+1
-0
PaddleCV/image_classification/infer.py
PaddleCV/image_classification/infer.py
+5
-2
未找到文件。
PaddleCV/image_classification/README.md
浏览文件 @
68d17711
...
...
@@ -277,6 +277,7 @@ python eval.py \
**参数说明:**
*
**data_dir**
: 数据存储位置,默认值:
`/data/ILSVRC2012/val/`
*
**save_inference**
: 是否保存二进制模型,默认值:
`False`
*
**topk**
: 按照置信由高到低排序标签结果,返回的结果数量,默认值:1
*
**class_map_path**
: 可读标签文件路径,默认值:
`./utils/tools/readable_label.txt`
...
...
PaddleCV/image_classification/infer.py
浏览文件 @
68d17711
...
...
@@ -36,7 +36,7 @@ from utils import *
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
# yapf: disable
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
add_arg
(
'data_dir'
,
str
,
"./data/ILSVRC2012/"
,
"The ImageNet data"
)
add_arg
(
'data_dir'
,
str
,
"./data/ILSVRC2012/
val/
"
,
"The ImageNet data"
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether to use GPU or not."
)
add_arg
(
'class_dim'
,
int
,
1000
,
"Class number."
)
parser
.
add_argument
(
"--pretrained_model"
,
default
=
None
,
required
=
True
,
type
=
str
,
help
=
"The path to load pretrained model"
)
...
...
@@ -148,6 +148,9 @@ def infer(args):
parallel_data
=
[]
parallel_id
=
[]
place_num
=
paddle
.
fluid
.
core
.
get_cuda_device_count
()
if
args
.
use_gpu
else
1
if
os
.
path
.
exists
(
args
.
save_json_path
):
logger
.
warning
(
"path: {} Already exists! will recover it
\n
"
.
format
(
args
.
save_json_path
))
with
open
(
args
.
save_json_path
,
"w"
)
as
fout
:
for
batch_id
,
data
in
enumerate
(
test_reader
()):
image_data
=
[[
items
[
0
]]
for
items
in
data
]
...
...
@@ -180,7 +183,7 @@ def infer(args):
info
[
real_id
][
'score'
],
info
[
real_id
][
'class'
]
=
str
(
res
[
pred_label
]),
str
(
pred_label
)
logger
.
info
(
real_id
,
info
[
real_id
]
)
logger
.
info
(
"{}, {}"
.
format
(
real_id
,
info
[
real_id
])
)
sys
.
stdout
.
flush
()
fout
.
write
(
real_id
+
"
\t
"
+
json
.
dumps
(
info
[
real_id
])
+
"
\n
"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录