Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
90d4a065
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看板
未验证
提交
90d4a065
编写于
9月 02, 2021
作者:
W
wangxinxin08
提交者:
GitHub
9月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify VOCDataSet and default value of allow_empty (#4096)
上级
e4982704
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
17 deletion
+20
-17
ppdet/data/source/coco.py
ppdet/data/source/coco.py
+2
-2
ppdet/data/source/voc.py
ppdet/data/source/voc.py
+18
-15
未找到文件。
ppdet/data/source/coco.py
浏览文件 @
90d4a065
...
...
@@ -48,7 +48,7 @@ class COCODataSet(DetDataset):
data_fields
=
[
'image'
],
sample_num
=-
1
,
load_crowd
=
False
,
allow_empty
=
Fals
e
,
allow_empty
=
Tru
e
,
empty_ratio
=
1.
):
super
(
COCODataSet
,
self
).
__init__
(
dataset_dir
,
image_dir
,
anno_path
,
data_fields
,
sample_num
)
...
...
@@ -243,7 +243,7 @@ class COCODataSet(DetDataset):
break
assert
ct
>
0
,
'not found any coco record in %s'
%
(
anno_path
)
logger
.
debug
(
'{} samples in file {}'
.
format
(
ct
,
anno_path
))
if
len
(
empty_records
)
>
0
:
if
self
.
allow_empty
and
len
(
empty_records
)
>
0
:
empty_records
=
self
.
_sample_empty
(
empty_records
,
len
(
records
))
records
+=
empty_records
self
.
roidbs
=
records
ppdet/data/source/voc.py
浏览文件 @
90d4a065
...
...
@@ -55,7 +55,7 @@ class VOCDataSet(DetDataset):
data_fields
=
[
'image'
],
sample_num
=-
1
,
label_list
=
None
,
allow_empty
=
Fals
e
,
allow_empty
=
Tru
e
,
empty_ratio
=
1.
):
super
(
VOCDataSet
,
self
).
__init__
(
dataset_dir
=
dataset_dir
,
...
...
@@ -131,11 +131,13 @@ class VOCDataSet(DetDataset):
'Illegal width: {} or height: {} in annotation, '
'and {} will be ignored'
.
format
(
im_w
,
im_h
,
xml_file
))
continue
gt_bbox
=
[]
gt_class
=
[]
gt_score
=
[]
difficult
=
[]
for
i
,
obj
in
enumerate
(
objs
):
num_bbox
,
i
=
len
(
objs
),
0
gt_bbox
=
np
.
zeros
((
num_bbox
,
4
),
dtype
=
np
.
float32
)
gt_class
=
np
.
zeros
((
num_bbox
,
1
),
dtype
=
np
.
int32
)
gt_score
=
np
.
zeros
((
num_bbox
,
1
),
dtype
=
np
.
float32
)
difficult
=
np
.
zeros
((
num_bbox
,
1
),
dtype
=
np
.
int32
)
for
obj
in
objs
:
cname
=
obj
.
find
(
'name'
).
text
# user dataset may not contain difficult field
...
...
@@ -152,19 +154,20 @@ class VOCDataSet(DetDataset):
x2
=
min
(
im_w
-
1
,
x2
)
y2
=
min
(
im_h
-
1
,
y2
)
if
x2
>
x1
and
y2
>
y1
:
gt_bbox
.
append
([
x1
,
y1
,
x2
,
y2
])
gt_class
.
append
([
cname2cid
[
cname
]])
gt_score
.
append
([
1.
])
difficult
.
append
([
_difficult
])
gt_bbox
[
i
,
:]
=
[
x1
,
y1
,
x2
,
y2
]
gt_class
[
i
,
0
]
=
cname2cid
[
cname
]
gt_score
[
i
,
0
]
=
1.
difficult
[
i
,
0
]
=
_difficult
i
+=
1
else
:
logger
.
warning
(
'Found an invalid bbox in annotations: xml_file: {}'
', x1: {}, y1: {}, x2: {}, y2: {}.'
.
format
(
xml_file
,
x1
,
y1
,
x2
,
y2
))
gt_bbox
=
np
.
array
(
gt_bbox
).
astype
(
'float32'
)
gt_class
=
np
.
array
(
gt_class
).
astype
(
'int32'
)
gt_score
=
np
.
array
(
gt_score
).
astype
(
'float32'
)
difficult
=
np
.
array
(
difficult
).
astype
(
'int32'
)
gt_bbox
=
gt_bbox
[:
i
,
:]
gt_class
=
gt_class
[:
i
,
:]
gt_score
=
gt_score
[:
i
,
:]
difficult
=
difficult
[:
i
,
:]
voc_rec
=
{
'im_file'
:
img_file
,
...
...
@@ -193,7 +196,7 @@ class VOCDataSet(DetDataset):
break
assert
ct
>
0
,
'not found any voc record in %s'
%
(
self
.
anno_path
)
logger
.
debug
(
'{} samples in file {}'
.
format
(
ct
,
anno_path
))
if
len
(
empty_records
)
>
0
:
if
self
.
allow_empty
and
len
(
empty_records
)
>
0
:
empty_records
=
self
.
_sample_empty
(
empty_records
,
len
(
records
))
records
+=
empty_records
self
.
roidbs
,
self
.
cname2cid
=
records
,
cname2cid
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录