Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
4f4211ef
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看板
提交
4f4211ef
编写于
7月 10, 2020
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
ca747f65
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
30 addition
and
64 deletion
+30
-64
paddlex/cv/datasets/easydata_cls.py
paddlex/cv/datasets/easydata_cls.py
+3
-9
paddlex/cv/datasets/easydata_det.py
paddlex/cv/datasets/easydata_det.py
+3
-9
paddlex/cv/datasets/easydata_seg.py
paddlex/cv/datasets/easydata_seg.py
+3
-9
paddlex/cv/datasets/imagenet.py
paddlex/cv/datasets/imagenet.py
+2
-7
paddlex/cv/datasets/seg_dataset.py
paddlex/cv/datasets/seg_dataset.py
+3
-9
paddlex/cv/datasets/voc.py
paddlex/cv/datasets/voc.py
+3
-9
paddlex/tools/x2coco.py
paddlex/tools/x2coco.py
+3
-12
paddlex/utils/__init__.py
paddlex/utils/__init__.py
+1
-0
paddlex/utils/utils.py
paddlex/utils/utils.py
+9
-0
未找到文件。
paddlex/cv/datasets/easydata_cls.py
浏览文件 @
4f4211ef
...
...
@@ -14,11 +14,11 @@
from
__future__
import
absolute_import
import
os.path
as
osp
import
platform
import
random
import
copy
import
json
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.imagenet
import
ImageNet
from
.dataset
import
is_pic
from
.dataset
import
get_encoding
...
...
@@ -65,18 +65,12 @@ class EasyDataCls(ImageNet):
item
=
line
.
strip
()
self
.
labels
.
append
(
item
)
logging
.
info
(
"Starting to read file list from dataset..."
)
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
file_list
,
encoding
=
get_encoding
(
file_list
))
as
f
:
for
line
in
f
:
img_file
,
json_file
=
[
osp
.
join
(
data_dir
,
x
)
\
for
x
in
line
.
strip
().
split
()[:
2
]]
if
platform
.
system
()
==
"Windows"
:
img_file
=
win_sep
.
join
(
img_file
.
split
(
other_sep
))
json_file
=
win_sep
.
join
(
json_file
.
split
(
other_sep
))
else
:
img_file
=
other_sep
.
join
(
img_file
.
split
(
win_sep
))
json_file
=
other_sep
.
join
(
json_file
.
split
(
win_sep
))
img_file
=
path_normalization
(
img_file
)
json_file
=
path_normalization
(
json_file
)
if
not
is_pic
(
img_file
):
continue
if
not
osp
.
isfile
(
json_file
):
...
...
paddlex/cv/datasets/easydata_det.py
浏览文件 @
4f4211ef
...
...
@@ -14,13 +14,13 @@
from
__future__
import
absolute_import
import
os.path
as
osp
import
platform
import
random
import
copy
import
json
import
cv2
import
numpy
as
np
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.voc
import
VOCDetection
from
.dataset
import
is_pic
from
.dataset
import
get_encoding
...
...
@@ -84,18 +84,12 @@ class EasyDataDet(VOCDetection):
from
pycocotools.mask
import
decode
ct
=
0
ann_ct
=
0
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
file_list
,
encoding
=
get_encoding
(
file_list
))
as
f
:
for
line
in
f
:
img_file
,
json_file
=
[
osp
.
join
(
data_dir
,
x
)
\
for
x
in
line
.
strip
().
split
()[:
2
]]
if
platform
.
system
()
==
"Windows"
:
img_file
=
win_sep
.
join
(
img_file
.
split
(
other_sep
))
json_file
=
win_sep
.
join
(
json_file
.
split
(
other_sep
))
else
:
img_file
=
other_sep
.
join
(
img_file
.
split
(
win_sep
))
json_file
=
other_sep
.
join
(
json_file
.
split
(
win_sep
))
img_file
=
path_normalization
(
img_file
)
json_file
=
path_normalization
(
json_file
)
if
not
is_pic
(
img_file
):
continue
if
not
osp
.
isfile
(
json_file
):
...
...
paddlex/cv/datasets/easydata_seg.py
浏览文件 @
4f4211ef
...
...
@@ -14,13 +14,13 @@
from
__future__
import
absolute_import
import
os.path
as
osp
import
platform
import
random
import
copy
import
json
import
cv2
import
numpy
as
np
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.dataset
import
Dataset
from
.dataset
import
get_encoding
from
.dataset
import
is_pic
...
...
@@ -62,8 +62,6 @@ class EasyDataSeg(Dataset):
from
pycocotools.mask
import
decode
cname2cid
=
{}
label_id
=
0
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
label_list
,
encoding
=
get_encoding
(
label_list
))
as
fr
:
for
line
in
fr
.
readlines
():
cname2cid
[
line
.
strip
()]
=
label_id
...
...
@@ -74,12 +72,8 @@ class EasyDataSeg(Dataset):
for
line
in
f
:
img_file
,
json_file
=
[
osp
.
join
(
data_dir
,
x
)
\
for
x
in
line
.
strip
().
split
()[:
2
]]
if
platform
.
system
()
==
"Windows"
:
img_file
=
win_sep
.
join
(
img_file
.
split
(
other_sep
))
json_file
=
win_sep
.
join
(
json_file
.
split
(
other_sep
))
else
:
img_file
=
other_sep
.
join
(
img_file
.
split
(
win_sep
))
json_file
=
other_sep
.
join
(
json_file
.
split
(
win_sep
))
img_file
=
path_normalization
(
img_file
)
json_file
=
path_normalization
(
json_file
)
if
not
is_pic
(
img_file
):
continue
if
not
osp
.
isfile
(
json_file
):
...
...
paddlex/cv/datasets/imagenet.py
浏览文件 @
4f4211ef
...
...
@@ -14,10 +14,10 @@
from
__future__
import
absolute_import
import
os.path
as
osp
import
platform
import
random
import
copy
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.dataset
import
Dataset
from
.dataset
import
is_pic
from
.dataset
import
get_encoding
...
...
@@ -64,15 +64,10 @@ class ImageNet(Dataset):
item
=
line
.
strip
()
self
.
labels
.
append
(
item
)
logging
.
info
(
"Starting to read file list from dataset..."
)
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
file_list
,
encoding
=
get_encoding
(
file_list
))
as
f
:
for
line
in
f
:
items
=
line
.
strip
().
split
()
if
platform
.
system
()
==
"Windows"
:
items
[
0
]
=
win_sep
.
join
(
items
[
0
].
split
(
other_sep
))
else
:
items
[
0
]
=
other_sep
.
join
(
items
[
0
].
split
(
win_sep
))
items
[
0
]
=
path_normalization
(
items
[
0
])
if
not
is_pic
(
items
[
0
]):
continue
full_path
=
osp
.
join
(
data_dir
,
items
[
0
])
...
...
paddlex/cv/datasets/seg_dataset.py
浏览文件 @
4f4211ef
...
...
@@ -14,10 +14,10 @@
from
__future__
import
absolute_import
import
os.path
as
osp
import
platform
import
random
import
copy
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.dataset
import
Dataset
from
.dataset
import
get_encoding
from
.dataset
import
is_pic
...
...
@@ -62,17 +62,11 @@ class SegDataset(Dataset):
for
line
in
f
:
item
=
line
.
strip
()
self
.
labels
.
append
(
item
)
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
file_list
,
encoding
=
get_encoding
(
file_list
))
as
f
:
for
line
in
f
:
items
=
line
.
strip
().
split
()
if
platform
.
system
()
==
"Windows"
:
items
[
0
]
=
win_sep
.
join
(
items
[
0
].
split
(
other_sep
))
items
[
1
]
=
win_sep
.
join
(
items
[
1
].
split
(
other_sep
))
else
:
items
[
0
]
=
other_sep
.
join
(
items
[
0
].
split
(
win_sep
))
items
[
1
]
=
other_sep
.
join
(
items
[
1
].
split
(
win_sep
))
items
[
0
]
=
path_normalization
(
items
[
0
])
items
[
1
]
=
path_normalization
(
items
[
1
])
if
not
is_pic
(
items
[
0
]):
continue
full_path_im
=
osp
.
join
(
data_dir
,
items
[
0
])
...
...
paddlex/cv/datasets/voc.py
浏览文件 @
4f4211ef
...
...
@@ -16,13 +16,13 @@ from __future__ import absolute_import
import
copy
import
os
import
os.path
as
osp
import
platform
import
random
import
re
import
numpy
as
np
from
collections
import
OrderedDict
import
xml.etree.ElementTree
as
ET
import
paddlex.utils.logging
as
logging
from
paddlex.utils
import
path_normalization
from
.dataset
import
Dataset
from
.dataset
import
is_pic
from
.dataset
import
get_encoding
...
...
@@ -86,8 +86,6 @@ class VOCDetection(Dataset):
})
ct
=
0
ann_ct
=
0
win_sep
=
"
\\
"
other_sep
=
"/"
with
open
(
file_list
,
'r'
,
encoding
=
get_encoding
(
file_list
))
as
fr
:
while
True
:
line
=
fr
.
readline
()
...
...
@@ -95,12 +93,8 @@ class VOCDetection(Dataset):
break
img_file
,
xml_file
=
[
osp
.
join
(
data_dir
,
x
)
\
for
x
in
line
.
strip
().
split
()[:
2
]]
if
platform
.
system
()
==
"Windows"
:
img_file
=
win_sep
.
join
(
img_file
.
split
(
other_sep
))
xml_file
=
win_sep
.
join
(
xml_file
.
split
(
other_sep
))
else
:
img_file
=
other_sep
.
join
(
img_file
.
split
(
win_sep
))
xml_file
=
other_sep
.
join
(
xml_file
.
split
(
win_sep
))
img_file
=
path_normalization
(
img_file
)
xml_file
=
path_normalization
(
xml_file
)
if
not
is_pic
(
img_file
):
continue
if
not
osp
.
isfile
(
xml_file
):
...
...
paddlex/tools/x2coco.py
浏览文件 @
4f4211ef
...
...
@@ -23,6 +23,7 @@ import shutil
import
numpy
as
np
import
PIL.ImageDraw
from
.base
import
MyEncoder
,
is_pic
,
get_encoding
from
paddlex.utils
import
path_normalization
class
X2COCO
(
object
):
...
...
@@ -101,12 +102,7 @@ class LabelMe2COCO(X2COCO):
image
[
"height"
]
=
json_info
[
"imageHeight"
]
image
[
"width"
]
=
json_info
[
"imageWidth"
]
image
[
"id"
]
=
image_id
+
1
win_sep
=
"
\\
"
other_sep
=
"/"
if
platform
.
system
()
==
"Windows"
:
json_info
[
"imagePath"
]
=
win_sep
.
join
(
json_info
[
"imagePath"
].
split
(
other_sep
))
else
:
json_info
[
"imagePath"
]
=
other_sep
.
join
(
json_info
[
"imagePath"
].
split
(
win_sep
))
json_info
[
"imagePath"
]
=
path_normalization
(
json_info
[
"imagePath"
])
image
[
"file_name"
]
=
osp
.
split
(
json_info
[
"imagePath"
])[
-
1
]
return
image
...
...
@@ -194,12 +190,7 @@ class EasyData2COCO(X2COCO):
image
[
"height"
]
=
img
.
shape
[
0
]
image
[
"width"
]
=
img
.
shape
[
1
]
image
[
"id"
]
=
image_id
+
1
win_sep
=
"
\\
"
other_sep
=
"/"
if
platform
.
system
()
==
"Windows"
:
img_path
=
win_sep
.
join
(
img_path
.
split
(
other_sep
))
else
:
img_path
=
other_sep
.
join
(
img_path
.
split
(
win_sep
))
img_path
=
path_normalization
(
img_path
)
image
[
"file_name"
]
=
osp
.
split
(
img_path
)[
-
1
]
return
image
...
...
paddlex/utils/__init__.py
浏览文件 @
4f4211ef
...
...
@@ -17,6 +17,7 @@ from . import logging
from
.
import
utils
from
.
import
save
from
.utils
import
seconds_to_hms
from
.utils
import
path_normalization
from
.download
import
download
from
.download
import
decompress
from
.download
import
download_and_decompress
paddlex/utils/utils.py
浏览文件 @
4f4211ef
...
...
@@ -20,6 +20,7 @@ import numpy as np
import
six
import
yaml
import
math
import
platform
from
.
import
logging
...
...
@@ -49,6 +50,14 @@ def get_environ_info():
info
[
'num'
]
=
fluid
.
core
.
get_cuda_device_count
()
return
info
def
path_normalization
(
path
):
win_sep
=
"
\\
"
other_sep
=
"/"
if
platform
.
system
()
==
"Windows"
:
path
=
win_sep
.
join
(
path
.
split
(
other_sep
))
else
:
path
=
other_sep
.
join
(
path
.
split
(
win_sep
))
return
path
def
parse_param_file
(
param_file
,
return_shape
=
True
):
from
paddle.fluid.proto.framework_pb2
import
VarType
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录