Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
3db718af
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3db718af
编写于
5月 22, 2020
作者:
S
sunyanfang01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the voc dataset
上级
02b1a99e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
10 deletion
+34
-10
paddlex/cv/datasets/voc.py
paddlex/cv/datasets/voc.py
+34
-10
未找到文件。
paddlex/cv/datasets/voc.py
浏览文件 @
3db718af
...
...
@@ -16,6 +16,7 @@ from __future__ import absolute_import
import
copy
import
os.path
as
osp
import
random
import
re
import
numpy
as
np
from
collections
import
OrderedDict
import
xml.etree.ElementTree
as
ET
...
...
@@ -103,23 +104,46 @@ class VOCDetection(Dataset):
else
:
ct
=
int
(
tree
.
find
(
'id'
).
text
)
im_id
=
np
.
array
([
int
(
tree
.
find
(
'id'
).
text
)])
objs
=
tree
.
findall
(
'object'
)
im_w
=
float
(
tree
.
find
(
'size'
).
find
(
'width'
).
text
)
im_h
=
float
(
tree
.
find
(
'size'
).
find
(
'height'
).
text
)
pattern
=
re
.
compile
(
'<object>'
,
re
.
IGNORECASE
)
obj_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
tree
.
getroot
())))[
0
][
1
:
-
1
]
objs
=
tree
.
findall
(
obj_tag
)
pattern
=
re
.
compile
(
'<size>'
,
re
.
IGNORECASE
)
size_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
tree
.
getroot
())))[
0
][
1
:
-
1
]
size_element
=
tree
.
find
(
size_tag
)
pattern
=
re
.
compile
(
'<width>'
,
re
.
IGNORECASE
)
width_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
size_element
)))[
0
][
1
:
-
1
]
im_w
=
float
(
size_element
.
find
(
width_tag
).
text
)
pattern
=
re
.
compile
(
'<height>'
,
re
.
IGNORECASE
)
height_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
size_element
)))[
0
][
1
:
-
1
]
im_h
=
float
(
size_element
.
find
(
height_tag
).
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
)
for
i
,
obj
in
enumerate
(
objs
):
cname
=
obj
.
find
(
'name'
).
text
pattern
=
re
.
compile
(
'<name>'
,
re
.
IGNORECASE
)
name_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
obj
)))[
0
][
1
:
-
1
]
cname
=
obj
.
find
(
name_tag
).
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
)
x2
=
float
(
obj
.
find
(
'bndbox'
).
find
(
'xmax'
).
text
)
y2
=
float
(
obj
.
find
(
'bndbox'
).
find
(
'ymax'
).
text
)
pattern
=
re
.
compile
(
'<difficult>'
,
re
.
IGNORECASE
)
diff_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
obj
)))[
0
][
1
:
-
1
]
_difficult
=
int
(
obj
.
find
(
diff_tag
).
text
)
pattern
=
re
.
compile
(
'<bndbox>'
,
re
.
IGNORECASE
)
box_tag
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
obj
)))[
0
][
1
:
-
1
]
box_element
=
obj
.
find
(
box_tag
)
pattern
=
re
.
compile
(
'<xmin>'
,
re
.
IGNORECASE
)
xmin_element
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
box_element
)))[
0
][
1
:
-
1
]
x1
=
float
(
box_element
.
find
(
xmin_element
).
text
)
pattern
=
re
.
compile
(
'<ymin>'
,
re
.
IGNORECASE
)
ymin_element
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
box_element
)))[
0
][
1
:
-
1
]
y1
=
float
(
box_element
.
find
(
ymin_element
).
text
)
pattern
=
re
.
compile
(
'<xmax>'
,
re
.
IGNORECASE
)
xmax_element
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
box_element
)))[
0
][
1
:
-
1
]
x2
=
float
(
box_element
.
find
(
xmax_element
).
text
)
pattern
=
re
.
compile
(
'<ymax>'
,
re
.
IGNORECASE
)
ymax_element
=
pattern
.
findall
(
str
(
ET
.
tostringlist
(
box_element
)))[
0
][
1
:
-
1
]
y2
=
float
(
box_element
.
find
(
ymax_element
).
text
)
x1
=
max
(
0
,
x1
)
y1
=
max
(
0
,
y1
)
if
im_w
>
0.5
and
im_h
>
0.5
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录