Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
e3fce291
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e3fce291
编写于
5月 12, 2020
作者:
W
wangguanzhong
提交者:
GitHub
5月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
filter illegal data (#646)
* filter illegal data * update warning message
上级
919310bb
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
59 addition
and
9 deletion
+59
-9
ppdet/data/source/coco.py
ppdet/data/source/coco.py
+10
-0
ppdet/data/source/voc.py
ppdet/data/source/voc.py
+33
-9
ppdet/data/source/widerface.py
ppdet/data/source/widerface.py
+3
-0
ppdet/data/transform/operators.py
ppdet/data/transform/operators.py
+13
-0
未找到文件。
ppdet/data/source/coco.py
浏览文件 @
e3fce291
...
...
@@ -106,6 +106,16 @@ class COCODataSet(DataSet):
im_fname
=
os
.
path
.
join
(
image_dir
,
im_fname
)
if
image_dir
else
im_fname
if
not
os
.
path
.
exists
(
im_fname
):
logger
.
warn
(
'Illegal image file: {}, and it will be '
'ignored'
.
format
(
im_fname
))
continue
if
im_w
<
0
or
im_h
<
0
:
logger
.
warn
(
'Illegal width: {} or height: {} in annotation, '
'and im_id: {} will be ignored'
.
format
(
im_w
,
im_h
,
img_id
))
continue
coco_rec
=
{
'im_file'
:
im_fname
,
...
...
ppdet/data/source/voc.py
浏览文件 @
e3fce291
...
...
@@ -110,7 +110,14 @@ class VOCDataSet(DataSet):
break
img_file
,
xml_file
=
[
os
.
path
.
join
(
image_dir
,
x
)
\
for
x
in
line
.
strip
().
split
()[:
2
]]
if
not
os
.
path
.
exists
(
img_file
):
logger
.
warn
(
'Illegal image file: {}, and it will be ignored'
.
format
(
img_file
))
continue
if
not
os
.
path
.
isfile
(
xml_file
):
logger
.
warn
(
'Illegal xml file: {}, and it will be ignored'
.
format
(
xml_file
))
continue
tree
=
ET
.
parse
(
xml_file
)
if
tree
.
find
(
'id'
)
is
None
:
...
...
@@ -121,14 +128,18 @@ class VOCDataSet(DataSet):
objs
=
tree
.
findall
(
'object'
)
im_w
=
float
(
tree
.
find
(
'size'
).
find
(
'width'
).
text
)
im_h
=
float
(
tree
.
find
(
'size'
).
find
(
'height'
).
text
)
gt_bbox
=
np
.
zeros
((
len
(
objs
),
4
),
dtype
=
np
.
float32
)
gt_class
=
np
.
zeros
((
len
(
objs
),
1
),
dtype
=
np
.
int32
)
gt_score
=
np
.
ones
((
len
(
objs
),
1
),
dtype
=
np
.
float32
)
is_crowd
=
np
.
zeros
((
len
(
objs
),
1
),
dtype
=
np
.
int32
)
difficult
=
np
.
zeros
((
len
(
objs
),
1
),
dtype
=
np
.
int32
)
if
im_w
<
0
or
im_h
<
0
:
logger
.
warn
(
'Illegal width: {} or height: {} in annotation, '
'and {} will be ignored'
.
format
(
im_w
,
im_h
,
xml_file
))
continue
gt_bbox
=
[]
gt_class
=
[]
gt_score
=
[]
is_crowd
=
[]
difficult
=
[]
for
i
,
obj
in
enumerate
(
objs
):
cname
=
obj
.
find
(
'name'
).
text
gt_class
[
i
][
0
]
=
cname2cid
[
cname
]
_difficult
=
int
(
obj
.
find
(
'difficult'
).
text
)
x1
=
float
(
obj
.
find
(
'bndbox'
).
find
(
'xmin'
).
text
)
y1
=
float
(
obj
.
find
(
'bndbox'
).
find
(
'ymin'
).
text
)
...
...
@@ -138,9 +149,22 @@ class VOCDataSet(DataSet):
y1
=
max
(
0
,
y1
)
x2
=
min
(
im_w
-
1
,
x2
)
y2
=
min
(
im_h
-
1
,
y2
)
gt_bbox
[
i
]
=
[
x1
,
y1
,
x2
,
y2
]
is_crowd
[
i
][
0
]
=
0
difficult
[
i
][
0
]
=
_difficult
if
x2
>
x1
and
y2
>
y1
:
gt_bbox
.
append
([
x1
,
y1
,
x2
,
y2
])
gt_class
.
append
([
cname2cid
[
cname
]])
gt_score
.
append
([
1.
])
is_crowd
.
append
([
0
])
difficult
.
append
([
_difficult
])
else
:
logger
.
warn
(
'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'
)
is_crowd
=
np
.
array
(
is_crowd
).
astype
(
'int32'
)
difficult
=
np
.
array
(
difficult
).
astype
(
'int32'
)
voc_rec
=
{
'im_file'
:
img_file
,
'im_id'
:
im_id
,
...
...
ppdet/data/source/widerface.py
浏览文件 @
e3fce291
...
...
@@ -79,6 +79,9 @@ class WIDERFaceDataSet(DataSet):
h
=
float
(
temp_info_box
[
3
])
# Filter out wrong labels
if
w
<
0
or
h
<
0
:
logger
.
warn
(
'Illegal box with w: {}, h: {} in '
'img: {}, and it will be ignored'
.
format
(
w
,
h
,
im_fname
))
continue
xmin
=
max
(
0
,
xmin
)
ymin
=
max
(
0
,
ymin
)
...
...
ppdet/data/transform/operators.py
浏览文件 @
e3fce291
...
...
@@ -121,8 +121,21 @@ class DecodeImage(BaseOperator):
if
'h'
not
in
sample
:
sample
[
'h'
]
=
im
.
shape
[
0
]
elif
sample
[
'h'
]
!=
im
.
shape
[
0
]:
logger
.
warn
(
"The actual image height: {} is not equal to the "
"height: {} in annotation, and update sample['h'] by actual "
"image height."
.
format
(
im
.
shape
[
0
],
sample
[
'h'
]))
sample
[
'h'
]
=
im
.
shape
[
0
]
if
'w'
not
in
sample
:
sample
[
'w'
]
=
im
.
shape
[
1
]
elif
sample
[
'w'
]
!=
im
.
shape
[
1
]:
logger
.
warn
(
"The actual image width: {} is not equal to the "
"width: {} in annotation, and update sample['w'] by actual "
"image width."
.
format
(
im
.
shape
[
1
],
sample
[
'w'
]))
sample
[
'w'
]
=
im
.
shape
[
1
]
# make default im_info with [h, w, 1]
sample
[
'im_info'
]
=
np
.
array
(
[
im
.
shape
[
0
],
im
.
shape
[
1
],
1.
],
dtype
=
np
.
float32
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录