Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f77d1bcc
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看板
未验证
提交
f77d1bcc
编写于
8月 01, 2022
作者:
W
wangguanzhong
提交者:
GitHub
8月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix voc save_result in infer (#6548)
上级
df669d42
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
2 deletion
+33
-2
ppdet/data/source/dataset.py
ppdet/data/source/dataset.py
+4
-0
ppdet/engine/trainer.py
ppdet/engine/trainer.py
+7
-1
ppdet/metrics/metrics.py
ppdet/metrics/metrics.py
+22
-1
未找到文件。
ppdet/data/source/dataset.py
浏览文件 @
f77d1bcc
...
@@ -203,6 +203,10 @@ class ImageFolder(DetDataset):
...
@@ -203,6 +203,10 @@ class ImageFolder(DetDataset):
self
.
image_dir
=
images
self
.
image_dir
=
images
self
.
roidbs
=
self
.
_load_images
()
self
.
roidbs
=
self
.
_load_images
()
def
get_label_list
(
self
):
# Only VOC dataset needs label list in ImageFold
return
self
.
anno_path
@
register
@
register
class
CommonDataset
(
object
):
class
CommonDataset
(
object
):
...
...
ppdet/engine/trainer.py
浏览文件 @
f77d1bcc
...
@@ -278,12 +278,18 @@ class Trainer(object):
...
@@ -278,12 +278,18 @@ class Trainer(object):
save_prediction_only
=
save_prediction_only
)
save_prediction_only
=
save_prediction_only
)
]
]
elif
self
.
cfg
.
metric
==
'VOC'
:
elif
self
.
cfg
.
metric
==
'VOC'
:
output_eval
=
self
.
cfg
[
'output_eval'
]
\
if
'output_eval'
in
self
.
cfg
else
None
save_prediction_only
=
self
.
cfg
.
get
(
'save_prediction_only'
,
False
)
self
.
_metrics
=
[
self
.
_metrics
=
[
VOCMetric
(
VOCMetric
(
label_list
=
self
.
dataset
.
get_label_list
(),
label_list
=
self
.
dataset
.
get_label_list
(),
class_num
=
self
.
cfg
.
num_classes
,
class_num
=
self
.
cfg
.
num_classes
,
map_type
=
self
.
cfg
.
map_type
,
map_type
=
self
.
cfg
.
map_type
,
classwise
=
classwise
)
classwise
=
classwise
,
output_eval
=
output_eval
,
save_prediction_only
=
save_prediction_only
)
]
]
elif
self
.
cfg
.
metric
==
'WiderFace'
:
elif
self
.
cfg
.
metric
==
'WiderFace'
:
multi_scale
=
self
.
cfg
.
multi_scale_eval
if
'multi_scale_eval'
in
self
.
cfg
else
True
multi_scale
=
self
.
cfg
.
multi_scale_eval
if
'multi_scale_eval'
in
self
.
cfg
else
True
...
...
ppdet/metrics/metrics.py
浏览文件 @
f77d1bcc
...
@@ -225,7 +225,9 @@ class VOCMetric(Metric):
...
@@ -225,7 +225,9 @@ class VOCMetric(Metric):
map_type
=
'11point'
,
map_type
=
'11point'
,
is_bbox_normalized
=
False
,
is_bbox_normalized
=
False
,
evaluate_difficult
=
False
,
evaluate_difficult
=
False
,
classwise
=
False
):
classwise
=
False
,
output_eval
=
None
,
save_prediction_only
=
False
):
assert
os
.
path
.
isfile
(
label_list
),
\
assert
os
.
path
.
isfile
(
label_list
),
\
"label_list {} not a file"
.
format
(
label_list
)
"label_list {} not a file"
.
format
(
label_list
)
self
.
clsid2catid
,
self
.
catid2name
=
get_categories
(
'VOC'
,
label_list
)
self
.
clsid2catid
,
self
.
catid2name
=
get_categories
(
'VOC'
,
label_list
)
...
@@ -233,6 +235,8 @@ class VOCMetric(Metric):
...
@@ -233,6 +235,8 @@ class VOCMetric(Metric):
self
.
overlap_thresh
=
overlap_thresh
self
.
overlap_thresh
=
overlap_thresh
self
.
map_type
=
map_type
self
.
map_type
=
map_type
self
.
evaluate_difficult
=
evaluate_difficult
self
.
evaluate_difficult
=
evaluate_difficult
self
.
output_eval
=
output_eval
self
.
save_prediction_only
=
save_prediction_only
self
.
detection_map
=
DetectionMAP
(
self
.
detection_map
=
DetectionMAP
(
class_num
=
class_num
,
class_num
=
class_num
,
overlap_thresh
=
overlap_thresh
,
overlap_thresh
=
overlap_thresh
,
...
@@ -245,6 +249,7 @@ class VOCMetric(Metric):
...
@@ -245,6 +249,7 @@ class VOCMetric(Metric):
self
.
reset
()
self
.
reset
()
def
reset
(
self
):
def
reset
(
self
):
self
.
results
=
{
'bbox'
:
[],
'score'
:
[],
'label'
:
[]}
self
.
detection_map
.
reset
()
self
.
detection_map
.
reset
()
def
update
(
self
,
inputs
,
outputs
):
def
update
(
self
,
inputs
,
outputs
):
...
@@ -256,8 +261,15 @@ class VOCMetric(Metric):
...
@@ -256,8 +261,15 @@ class VOCMetric(Metric):
bbox_lengths
=
outputs
[
'bbox_num'
].
numpy
()
if
isinstance
(
bbox_lengths
=
outputs
[
'bbox_num'
].
numpy
()
if
isinstance
(
outputs
[
'bbox_num'
],
paddle
.
Tensor
)
else
outputs
[
'bbox_num'
]
outputs
[
'bbox_num'
],
paddle
.
Tensor
)
else
outputs
[
'bbox_num'
]
self
.
results
[
'bbox'
].
append
(
bboxes
.
tolist
())
self
.
results
[
'score'
].
append
(
scores
.
tolist
())
self
.
results
[
'label'
].
append
(
labels
.
tolist
())
if
bboxes
.
shape
==
(
1
,
1
)
or
bboxes
is
None
:
if
bboxes
.
shape
==
(
1
,
1
)
or
bboxes
is
None
:
return
return
if
self
.
save_prediction_only
:
return
gt_boxes
=
inputs
[
'gt_bbox'
]
gt_boxes
=
inputs
[
'gt_bbox'
]
gt_labels
=
inputs
[
'gt_class'
]
gt_labels
=
inputs
[
'gt_class'
]
difficults
=
inputs
[
'difficult'
]
if
not
self
.
evaluate_difficult
\
difficults
=
inputs
[
'difficult'
]
if
not
self
.
evaluate_difficult
\
...
@@ -294,6 +306,15 @@ class VOCMetric(Metric):
...
@@ -294,6 +306,15 @@ class VOCMetric(Metric):
bbox_idx
+=
bbox_num
bbox_idx
+=
bbox_num
def
accumulate
(
self
):
def
accumulate
(
self
):
output
=
"bbox.json"
if
self
.
output_eval
:
output
=
os
.
path
.
join
(
self
.
output_eval
,
output
)
with
open
(
output
,
'w'
)
as
f
:
json
.
dump
(
self
.
results
,
f
)
logger
.
info
(
'The bbox result is saved to bbox.json.'
)
if
self
.
save_prediction_only
:
return
logger
.
info
(
"Accumulating evaluatation results..."
)
logger
.
info
(
"Accumulating evaluatation results..."
)
self
.
detection_map
.
accumulate
()
self
.
detection_map
.
accumulate
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录