Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
1292af43
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看板
提交
1292af43
编写于
8月 08, 2019
作者:
K
Kaipeng Deng
提交者:
GitHub
8月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix yolov3 voc eval in train (#3053)
* fix yolov3 voc eval in train * fix comment
上级
577b4ba9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
27 deletion
+61
-27
ppdet/data/data_feed.py
ppdet/data/data_feed.py
+1
-0
ppdet/data/transform/arrange_sample.py
ppdet/data/transform/arrange_sample.py
+10
-5
ppdet/modeling/model_input.py
ppdet/modeling/model_input.py
+2
-0
ppdet/utils/map_utils.py
ppdet/utils/map_utils.py
+2
-2
ppdet/utils/voc_eval.py
ppdet/utils/voc_eval.py
+41
-18
tools/train.py
tools/train.py
+5
-2
未找到文件。
ppdet/data/data_feed.py
浏览文件 @
1292af43
...
@@ -936,6 +936,7 @@ class YoloEvalFeed(DataFeed):
...
@@ -936,6 +936,7 @@ class YoloEvalFeed(DataFeed):
with_background
=
with_background
,
with_background
=
with_background
,
num_workers
=
num_workers
,
num_workers
=
num_workers
,
use_process
=
use_process
)
use_process
=
use_process
)
self
.
num_max_boxes
=
num_max_boxes
self
.
mode
=
'VAL'
self
.
mode
=
'VAL'
self
.
bufsize
=
128
self
.
bufsize
=
128
...
...
ppdet/data/transform/arrange_sample.py
浏览文件 @
1292af43
...
@@ -245,8 +245,8 @@ class ArrangeEvalYOLO(BaseOperator):
...
@@ -245,8 +245,8 @@ class ArrangeEvalYOLO(BaseOperator):
context: a dict which contains additional info.
context: a dict which contains additional info.
Returns:
Returns:
sample: a tuple containing the following items:
sample: a tuple containing the following items:
(image,
gt_bbox, gt_class, gt_score
,
(image,
im_shape, im_id, gt_bbox, gt_class
,
is_crowd, im_info, gt_masks
)
difficult
)
"""
"""
im
=
sample
[
'image'
]
im
=
sample
[
'image'
]
if
len
(
sample
[
'gt_bbox'
])
!=
len
(
sample
[
'gt_class'
]):
if
len
(
sample
[
'gt_bbox'
])
!=
len
(
sample
[
'gt_class'
]):
...
@@ -255,9 +255,14 @@ class ArrangeEvalYOLO(BaseOperator):
...
@@ -255,9 +255,14 @@ class ArrangeEvalYOLO(BaseOperator):
h
=
sample
[
'h'
]
h
=
sample
[
'h'
]
w
=
sample
[
'w'
]
w
=
sample
[
'w'
]
im_shape
=
np
.
array
((
h
,
w
))
im_shape
=
np
.
array
((
h
,
w
))
gt_bbox
=
sample
[
'gt_bbox'
]
gt_bbox
=
np
.
zeros
((
50
,
4
),
dtype
=
im
.
dtype
)
gt_class
=
sample
[
'gt_class'
]
gt_class
=
np
.
zeros
((
50
,
),
dtype
=
np
.
int32
)
difficult
=
sample
[
'difficult'
]
difficult
=
np
.
zeros
((
50
,
),
dtype
=
np
.
int32
)
gt_num
=
min
(
50
,
len
(
sample
[
'gt_bbox'
]))
if
gt_num
>
0
:
gt_bbox
[:
gt_num
,
:]
=
sample
[
'gt_bbox'
][:
gt_num
,
:]
gt_class
[:
gt_num
]
=
sample
[
'gt_class'
][:
gt_num
,
0
]
difficult
[:
gt_num
]
=
sample
[
'difficult'
][:
gt_num
,
0
]
outs
=
(
im
,
im_shape
,
im_id
,
gt_bbox
,
gt_class
,
difficult
)
outs
=
(
im
,
im_shape
,
im_id
,
gt_bbox
,
gt_class
,
difficult
)
return
outs
return
outs
...
...
ppdet/modeling/model_input.py
浏览文件 @
1292af43
...
@@ -54,9 +54,11 @@ def create_feed(feed, use_pyreader=True):
...
@@ -54,9 +54,11 @@ def create_feed(feed, use_pyreader=True):
feed_var_map
[
'gt_label'
][
'shape'
]
=
[
feed
.
num_max_boxes
]
feed_var_map
[
'gt_label'
][
'shape'
]
=
[
feed
.
num_max_boxes
]
feed_var_map
[
'gt_score'
][
'shape'
]
=
[
feed
.
num_max_boxes
]
feed_var_map
[
'gt_score'
][
'shape'
]
=
[
feed
.
num_max_boxes
]
feed_var_map
[
'gt_box'
][
'shape'
]
=
[
feed
.
num_max_boxes
,
4
]
feed_var_map
[
'gt_box'
][
'shape'
]
=
[
feed
.
num_max_boxes
,
4
]
feed_var_map
[
'is_difficult'
][
'shape'
]
=
[
feed
.
num_max_boxes
]
feed_var_map
[
'gt_label'
][
'lod_level'
]
=
0
feed_var_map
[
'gt_label'
][
'lod_level'
]
=
0
feed_var_map
[
'gt_score'
][
'lod_level'
]
=
0
feed_var_map
[
'gt_score'
][
'lod_level'
]
=
0
feed_var_map
[
'gt_box'
][
'lod_level'
]
=
0
feed_var_map
[
'gt_box'
][
'lod_level'
]
=
0
feed_var_map
[
'is_difficult'
][
'lod_level'
]
=
0
feed_vars
=
OrderedDict
([(
key
,
fluid
.
layers
.
data
(
feed_vars
=
OrderedDict
([(
key
,
fluid
.
layers
.
data
(
name
=
feed_var_map
[
key
][
'name'
],
name
=
feed_var_map
[
key
][
'name'
],
...
...
ppdet/utils/map_utils.py
浏览文件 @
1292af43
...
@@ -105,7 +105,7 @@ class DetectionMAP(object):
...
@@ -105,7 +105,7 @@ class DetectionMAP(object):
# record class gt count
# record class gt count
for
gtl
,
diff
in
zip
(
gt_label
,
difficult
):
for
gtl
,
diff
in
zip
(
gt_label
,
difficult
):
if
self
.
evaluate_difficult
or
int
(
diff
)
==
0
:
if
self
.
evaluate_difficult
or
int
(
diff
)
==
0
:
self
.
class_gt_counts
[
int
(
gtl
[
0
]
)]
+=
1
self
.
class_gt_counts
[
int
(
np
.
array
(
gtl
)
)]
+=
1
# record class score positive
# record class score positive
visited
=
[
False
]
*
len
(
gt_label
)
visited
=
[
False
]
*
len
(
gt_label
)
...
@@ -124,7 +124,7 @@ class DetectionMAP(object):
...
@@ -124,7 +124,7 @@ class DetectionMAP(object):
if
max_overlap
>
self
.
overlap_thresh
:
if
max_overlap
>
self
.
overlap_thresh
:
if
self
.
evaluate_difficult
or
\
if
self
.
evaluate_difficult
or
\
int
(
difficult
[
max_idx
]
)
==
0
:
int
(
np
.
array
(
difficult
[
max_idx
])
)
==
0
:
if
not
visited
[
max_idx
]:
if
not
visited
[
max_idx
]:
self
.
class_score_poss
[
self
.
class_score_poss
[
int
(
label
)].
append
([
score
,
1.0
])
int
(
label
)].
append
([
score
,
1.0
])
...
...
ppdet/utils/voc_eval.py
浏览文件 @
1292af43
...
@@ -71,27 +71,39 @@ def bbox_eval(results,
...
@@ -71,27 +71,39 @@ def bbox_eval(results,
continue
continue
gt_boxes
=
t
[
'gt_box'
][
0
]
gt_boxes
=
t
[
'gt_box'
][
0
]
gt_box_lengths
=
t
[
'gt_box'
][
1
][
0
]
gt_labels
=
t
[
'gt_label'
][
0
]
gt_labels
=
t
[
'gt_label'
][
0
]
assert
len
(
gt_boxes
)
==
len
(
gt_labels
)
difficults
=
t
[
'is_difficult'
][
0
]
if
not
evaluate_difficult
\
difficults
=
t
[
'is_difficult'
][
0
]
if
not
evaluate_difficult
\
else
None
else
None
if
not
evaluate_difficult
:
assert
len
(
gt_labels
)
==
len
(
difficults
)
if
len
(
t
[
'gt_box'
][
1
])
==
0
:
# gt_box, gt_label, difficult read as zero padded Tensor
bbox_idx
=
0
bbox_idx
=
0
gt_box_idx
=
0
for
i
in
range
(
len
(
gt_boxes
)):
for
i
in
range
(
len
(
bbox_lengths
)):
gt_box
=
gt_boxes
[
i
]
bbox_num
=
bbox_lengths
[
i
]
gt_label
=
gt_labels
[
i
]
gt_box_num
=
gt_box_lengths
[
i
]
difficult
=
difficults
[
i
]
bbox
=
bboxes
[
bbox_idx
:
bbox_idx
+
bbox_num
]
bbox_num
=
bbox_lengths
[
i
]
gt_box
=
gt_boxes
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
bbox
=
bboxes
[
bbox_idx
:
bbox_idx
+
bbox_num
]
gt_label
=
gt_labels
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
gt_box
,
gt_label
,
difficult
=
prune_zero_padding
(
difficult
=
None
if
difficults
is
None
else
\
gt_box
,
gt_label
,
difficult
)
difficults
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
detection_map
.
update
(
bbox
,
gt_box
,
gt_label
,
difficult
)
detection_map
.
update
(
bbox
,
gt_box
,
gt_label
,
difficult
)
bbox_idx
+=
bbox_num
bbox_idx
+=
bbox_num
else
:
gt_box_idx
+=
gt_box_num
# gt_box, gt_label, difficult read as LoDTensor
gt_box_lengths
=
t
[
'gt_box'
][
1
][
0
]
bbox_idx
=
0
gt_box_idx
=
0
for
i
in
range
(
len
(
bbox_lengths
)):
bbox_num
=
bbox_lengths
[
i
]
gt_box_num
=
gt_box_lengths
[
i
]
bbox
=
bboxes
[
bbox_idx
:
bbox_idx
+
bbox_num
]
gt_box
=
gt_boxes
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
gt_label
=
gt_labels
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
difficult
=
None
if
difficults
is
None
else
\
difficults
[
gt_box_idx
:
gt_box_idx
+
gt_box_num
]
detection_map
.
update
(
bbox
,
gt_box
,
gt_label
,
difficult
)
bbox_idx
+=
bbox_num
gt_box_idx
+=
gt_box_num
logger
.
info
(
"Accumulating evaluatation results..."
)
logger
.
info
(
"Accumulating evaluatation results..."
)
detection_map
.
accumulate
()
detection_map
.
accumulate
()
...
@@ -99,6 +111,17 @@ def bbox_eval(results,
...
@@ -99,6 +111,17 @@ def bbox_eval(results,
map_type
,
100.
*
detection_map
.
get_map
()))
map_type
,
100.
*
detection_map
.
get_map
()))
def
prune_zero_padding
(
gt_box
,
gt_label
,
difficult
=
None
):
valid_cnt
=
0
for
i
in
range
(
len
(
gt_box
)):
if
gt_box
[
i
,
0
]
==
0
and
gt_box
[
i
,
1
]
==
0
and
\
gt_box
[
i
,
2
]
==
0
and
gt_box
[
i
,
3
]
==
0
:
break
valid_cnt
+=
1
return
(
gt_box
[:
valid_cnt
],
gt_label
[:
valid_cnt
],
difficult
[:
valid_cnt
]
if
difficult
is
not
None
else
None
)
def
get_category_info
(
anno_file
=
None
,
def
get_category_info
(
anno_file
=
None
,
with_background
=
True
,
with_background
=
True
,
use_default_label
=
False
):
use_default_label
=
False
):
...
...
tools/train.py
浏览文件 @
1292af43
...
@@ -123,8 +123,11 @@ def main():
...
@@ -123,8 +123,11 @@ def main():
eval_pyreader
.
decorate_sample_list_generator
(
eval_reader
,
place
)
eval_pyreader
.
decorate_sample_list_generator
(
eval_reader
,
place
)
# parse eval fetches
# parse eval fetches
extra_keys
=
[
'im_info'
,
'im_id'
,
extra_keys
=
[]
'im_shape'
]
if
cfg
.
metric
==
'COCO'
else
[]
if
cfg
.
metric
==
'COCO'
:
extra_keys
=
[
'im_info'
,
'im_id'
,
'im_shape'
]
if
cfg
.
metric
==
'VOC'
:
extra_keys
=
[
'gt_box'
,
'gt_label'
,
'is_difficult'
]
eval_keys
,
eval_values
,
eval_cls
=
parse_fetches
(
fetches
,
eval_prog
,
eval_keys
,
eval_values
,
eval_cls
=
parse_fetches
(
fetches
,
eval_prog
,
extra_keys
)
extra_keys
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录