Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
effbad5d
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
effbad5d
编写于
4月 14, 2021
作者:
S
shangliang Xu
提交者:
GitHub
4月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add save only in eval (#2608)
上级
78fdd43e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
13 deletion
+43
-13
dygraph/ppdet/engine/trainer.py
dygraph/ppdet/engine/trainer.py
+5
-1
dygraph/ppdet/metrics/metrics.py
dygraph/ppdet/metrics/metrics.py
+25
-12
dygraph/tools/eval.py
dygraph/tools/eval.py
+7
-0
dygraph/tools/train.py
dygraph/tools/train.py
+6
-0
未找到文件。
dygraph/ppdet/engine/trainer.py
浏览文件 @
effbad5d
...
...
@@ -116,9 +116,13 @@ class Trainer(object):
if
self
.
cfg
.
metric
==
'COCO'
:
# TODO: bias should be unified
bias
=
self
.
cfg
[
'bias'
]
if
'bias'
in
self
.
cfg
else
0
save_prediction_only
=
self
.
cfg
[
'save_prediction_only'
]
\
if
'save_prediction_only'
in
self
.
cfg
else
False
self
.
_metrics
=
[
COCOMetric
(
anno_file
=
self
.
dataset
.
get_anno
(),
bias
=
bias
)
anno_file
=
self
.
dataset
.
get_anno
(),
bias
=
bias
,
save_prediction_only
=
save_prediction_only
)
]
elif
self
.
cfg
.
metric
==
'VOC'
:
self
.
_metrics
=
[
...
...
dygraph/ppdet/metrics/metrics.py
浏览文件 @
effbad5d
...
...
@@ -65,6 +65,7 @@ class COCOMetric(Metric):
self
.
clsid2catid
,
self
.
catid2name
=
get_categories
(
'COCO'
,
anno_file
)
# TODO: bias should be unified
self
.
bias
=
kwargs
.
get
(
'bias'
,
0
)
self
.
save_prediction_only
=
kwargs
.
get
(
'save_prediction_only'
,
False
)
self
.
reset
()
def
reset
(
self
):
...
...
@@ -97,30 +98,42 @@ class COCOMetric(Metric):
json
.
dump
(
self
.
results
[
'bbox'
],
f
)
logger
.
info
(
'The bbox result is saved to bbox.json.'
)
bbox_stats
=
cocoapi_eval
(
'bbox.json'
,
'bbox'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'bbox'
]
=
bbox_stats
sys
.
stdout
.
flush
()
if
self
.
save_prediction_only
:
logger
.
info
(
'The bbox result is saved to bbox.json and do not '
'evaluate the mAP.'
)
else
:
bbox_stats
=
cocoapi_eval
(
'bbox.json'
,
'bbox'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'bbox'
]
=
bbox_stats
sys
.
stdout
.
flush
()
if
len
(
self
.
results
[
'mask'
])
>
0
:
with
open
(
"mask.json"
,
'w'
)
as
f
:
json
.
dump
(
self
.
results
[
'mask'
],
f
)
logger
.
info
(
'The mask result is saved to mask.json.'
)
seg_stats
=
cocoapi_eval
(
'mask.json'
,
'segm'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'mask'
]
=
seg_stats
sys
.
stdout
.
flush
()
if
self
.
save_prediction_only
:
logger
.
info
(
'The mask result is saved to mask.json and do not '
'evaluate the mAP.'
)
else
:
seg_stats
=
cocoapi_eval
(
'mask.json'
,
'segm'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'mask'
]
=
seg_stats
sys
.
stdout
.
flush
()
if
len
(
self
.
results
[
'segm'
])
>
0
:
with
open
(
"segm.json"
,
'w'
)
as
f
:
json
.
dump
(
self
.
results
[
'segm'
],
f
)
logger
.
info
(
'The segm result is saved to segm.json.'
)
seg_stats
=
cocoapi_eval
(
'segm.json'
,
'segm'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'mask'
]
=
seg_stats
sys
.
stdout
.
flush
()
if
self
.
save_prediction_only
:
logger
.
info
(
'The segm result is saved to segm.json and do not '
'evaluate the mAP.'
)
else
:
seg_stats
=
cocoapi_eval
(
'segm.json'
,
'segm'
,
anno_file
=
self
.
anno_file
)
self
.
eval_results
[
'mask'
]
=
seg_stats
sys
.
stdout
.
flush
()
def
log
(
self
):
pass
...
...
dygraph/tools/eval.py
浏览文件 @
effbad5d
...
...
@@ -64,6 +64,12 @@ def parse_args():
action
=
"store_true"
,
help
=
"whether add bias or not while getting w and h"
)
parser
.
add_argument
(
'--save_prediction_only'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Whether to save the evaluation results only'
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -88,6 +94,7 @@ def main():
cfg
=
load_config
(
FLAGS
.
config
)
# TODO: bias should be unified
cfg
[
'bias'
]
=
1
if
FLAGS
.
bias
else
0
cfg
[
'save_prediction_only'
]
=
FLAGS
.
save_prediction_only
merge_config
(
FLAGS
.
opt
)
if
FLAGS
.
slim_config
:
slim_cfg
=
load_config
(
FLAGS
.
slim_config
)
...
...
dygraph/tools/train.py
浏览文件 @
effbad5d
...
...
@@ -65,6 +65,11 @@ def parse_args():
default
=
False
,
help
=
"If set True, enable continuous evaluation job."
"This flag is only used for internal test."
)
parser
.
add_argument
(
'--save_prediction_only'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Whether to save the evaluation results only'
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -91,6 +96,7 @@ def main():
FLAGS
=
parse_args
()
cfg
=
load_config
(
FLAGS
.
config
)
cfg
[
'save_prediction_only'
]
=
FLAGS
.
save_prediction_only
merge_config
(
FLAGS
.
opt
)
if
FLAGS
.
slim_config
:
slim_cfg
=
load_config
(
FLAGS
.
slim_config
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录