Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
967ebd6f
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
286
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
967ebd6f
编写于
8月 06, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update datasets
上级
c4bf7ab3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
44 addition
and
47 deletion
+44
-47
dygraph/datasets/__init__.py
dygraph/datasets/__init__.py
+7
-1
dygraph/datasets/voc.py
dygraph/datasets/voc.py
+2
-2
dygraph/infer.py
dygraph/infer.py
+7
-11
dygraph/tools/voc_augment.py
dygraph/tools/voc_augment.py
+14
-11
dygraph/train.py
dygraph/train.py
+7
-11
dygraph/val.py
dygraph/val.py
+7
-11
未找到文件。
dygraph/datasets/__init__.py
浏览文件 @
967ebd6f
...
...
@@ -15,4 +15,10 @@
from
.dataset
import
Dataset
from
.optic_disc_seg
import
OpticDiscSeg
from
.cityscapes
import
Cityscapes
from
.voc
import
PascalVoc
from
.voc
import
PascalVOC
DATASETS
=
{
"OpticDiscSeg"
:
OpticDiscSeg
,
"Cityscapes"
:
Cityscapes
,
"PascalVOC"
:
PascalVOC
}
dygraph/datasets/voc.py
浏览文件 @
967ebd6f
...
...
@@ -20,7 +20,7 @@ DATA_HOME = os.path.expanduser('~/.cache/paddle/dataset')
URL
=
"https://paddleseg.bj.bcebos.com/dataset/VOCtrainval_11-May-2012.tar"
class
PascalV
oc
(
Dataset
):
class
PascalV
OC
(
Dataset
):
"""Pascal VOC dataset `http://host.robots.ox.ac.uk/pascal/VOC/`. If you want to augment the dataset,
please run the voc_augment.py in tools.
Args:
...
...
@@ -36,7 +36,7 @@ class PascalVoc(Dataset):
image_set
=
'train'
,
mode
=
'train'
,
transforms
=
None
,
download
=
Fals
e
):
download
=
Tru
e
):
self
.
data_dir
=
data_dir
self
.
transforms
=
transforms
self
.
mode
=
mode
...
...
dygraph/infer.py
浏览文件 @
967ebd6f
...
...
@@ -22,7 +22,7 @@ from paddle.fluid.dygraph.parallel import ParallelEnv
import
cv2
import
tqdm
from
datasets
import
OpticDiscSeg
,
Cityscapes
from
datasets
import
DATASETS
import
transforms
as
T
from
models
import
MODELS
import
utils
...
...
@@ -47,8 +47,8 @@ def parse_args():
parser
.
add_argument
(
'--dataset'
,
dest
=
'dataset'
,
help
=
"The dataset you want to train, which is one of ('OpticDiscSeg', 'Cityscapes')"
,
help
=
"The dataset you want to test, which is one of {}"
.
format
(
str
(
list
(
DATASETS
.
keys
())))
,
type
=
str
,
default
=
'OpticDiscSeg'
)
...
...
@@ -88,14 +88,10 @@ def main(args):
if
env_info
[
'place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
.
lower
()
==
'opticdiscseg'
:
dataset
=
OpticDiscSeg
elif
args
.
dataset
.
lower
()
==
'cityscapes'
:
dataset
=
Cityscapes
else
:
raise
Exception
(
"The --dataset set wrong. It should be one of ('OpticDiscSeg', 'Cityscapes')"
)
if
args
.
dataset
not
in
DATASETS
:
raise
Exception
(
'--dataset is invalid. it should be one of {}'
.
format
(
str
(
list
(
DATASETS
.
keys
()))))
dataset
=
DATASETS
[
args
.
dataset
]
with
fluid
.
dygraph
.
guard
(
places
):
test_transforms
=
T
.
Compose
([
T
.
Resize
(
args
.
input_size
),
T
.
Normalize
()])
...
...
dygraph/tools/voc_augment.py
浏览文件 @
967ebd6f
...
...
@@ -43,18 +43,18 @@ def parse_args():
dest
=
'voc_path'
,
help
=
'pascal voc path'
,
type
=
str
,
default
=
os
.
path
.
join
(
DATA_HOME
+
'VOCdevkit'
))
default
=
os
.
path
.
join
(
DATA_HOME
,
'VOCdevkit'
))
parser
.
add_argument
(
'--num_workers'
,
dest
=
'num_workers'
,
help
=
'How many processes are used for data conversion'
,
type
=
str
,
type
=
int
,
default
=
cpu_count
())
return
parser
.
parse_args
()
def
conver
_to_png
(
mat_file
,
sbd_cls_dir
,
save_dir
):
def
mat
_to_png
(
mat_file
,
sbd_cls_dir
,
save_dir
):
mat_path
=
os
.
path
.
join
(
sbd_cls_dir
,
mat_file
)
mat
=
loadmat
(
mat_path
)
mask
=
mat
[
'GTcls'
][
0
][
'Segmentation'
][
0
].
astype
(
np
.
uint8
)
...
...
@@ -75,27 +75,30 @@ def main():
sbd_file_list
+=
[
line
.
strip
()
for
line
in
f
]
if
not
os
.
path
.
exists
(
args
.
voc_path
):
raise
Exception
(
'Ther is no voc_path: {}. Please ensure that the Pascal VOC dataset has been downloaded correctly'
'Ther
e
is no voc_path: {}. Please ensure that the Pascal VOC dataset has been downloaded correctly'
)
with
open
(
os
.
path
.
join
(
args
.
voc_path
,
'VOC2012/ImageSets/Segmentation/trainval.txt'
,
'r'
)
)
as
f
:
'VOC2012/ImageSets/Segmentation/trainval.txt'
)
,
'r'
)
as
f
:
voc_file_list
=
[
line
.
strip
()
for
line
in
f
]
aug_file_list
=
list
(
set
(
sbd_file_list
)
-
set
(
voc_file_list
))
with
open
(
os
.
path
.
join
(
args
.
voc_path
,
'VOC2012/ImageSets/Segmentation/aug.txt'
,
'w'
)
)
as
f
:
f
.
writelines
(
''
.
join
(
line
,
'
\n
'
)
for
line
in
aug_file_list
)
'VOC2012/ImageSets/Segmentation/aug.txt'
),
'w'
)
as
f
:
f
.
writelines
(
''
.
join
(
[
line
,
'
\n
'
]
)
for
line
in
aug_file_list
)
sbd_cls_dir
=
os
.
path
.
join
(
sbd_path
,
'dataset/cls'
)
save_dir
=
os
.
path
.
join
(
args
.
voc_path
,
'VOC2012/ImageSets/SegmentationClassAug'
)
save_dir
=
os
.
path
.
join
(
args
.
voc_path
,
'VOC2012/SegmentationClassAug'
)
if
not
os
.
path
.
exists
(
save_dir
):
os
.
mkdir
(
save_dir
)
mat_file_list
=
os
.
listdir
(
sbd_cls_dir
)
p
=
Pool
(
args
.
num_workers
)
for
f
in
tqdm
.
tqdm
(
mat_file_list
):
p
.
apply_async
(
conver_to_png
,
args
=
(
f
,
sbd_cls_dir
,
save_dir
))
p
.
apply_async
(
mat_to_png
,
args
=
(
f
,
sbd_cls_dir
,
save_dir
))
p
.
close
()
p
.
join
()
if
__name__
==
'__main__'
:
...
...
dygraph/train.py
浏览文件 @
967ebd6f
...
...
@@ -20,7 +20,7 @@ from paddle.fluid.dygraph.parallel import ParallelEnv
from
paddle.fluid.io
import
DataLoader
from
paddle.incubate.hapi.distributed
import
DistributedBatchSampler
from
datasets
import
OpticDiscSeg
,
Cityscapes
from
datasets
import
DATASETS
import
transforms
as
T
from
models
import
MODELS
import
utils.logging
as
logging
...
...
@@ -47,8 +47,8 @@ def parse_args():
parser
.
add_argument
(
'--dataset'
,
dest
=
'dataset'
,
help
=
"The dataset you want to train, which is one of ('OpticDiscSeg', 'Cityscapes')"
,
help
=
"The dataset you want to train, which is one of {}"
.
format
(
str
(
list
(
DATASETS
.
keys
())))
,
type
=
str
,
default
=
'OpticDiscSeg'
)
...
...
@@ -134,14 +134,10 @@ def main(args):
if
env_info
[
'place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
.
lower
()
==
'opticdiscseg'
:
dataset
=
OpticDiscSeg
elif
args
.
dataset
.
lower
()
==
'cityscapes'
:
dataset
=
Cityscapes
else
:
raise
Exception
(
"The --dataset set wrong. It should be one of ('OpticDiscSeg', 'Cityscapes')"
)
if
args
.
dataset
not
in
DATASETS
:
raise
Exception
(
'--dataset is invalid. it should be one of {}'
.
format
(
str
(
list
(
DATASETS
.
keys
()))))
dataset
=
DATASETS
[
args
.
dataset
]
with
fluid
.
dygraph
.
guard
(
places
):
# Creat dataset reader
...
...
dygraph/val.py
浏览文件 @
967ebd6f
...
...
@@ -25,7 +25,7 @@ from paddle.fluid.dygraph.parallel import ParallelEnv
from
paddle.fluid.io
import
DataLoader
from
paddle.fluid.dataloader
import
BatchSampler
from
datasets
import
OpticDiscSeg
,
Cityscapes
from
datasets
import
DATASETS
import
transforms
as
T
from
models
import
MODELS
import
utils.logging
as
logging
...
...
@@ -51,8 +51,8 @@ def parse_args():
parser
.
add_argument
(
'--dataset'
,
dest
=
'dataset'
,
help
=
"The dataset you want to evaluation, which is one of ('OpticDiscSeg', 'Cityscapes')"
,
help
=
"The dataset you want to evaluation, which is one of {}"
.
format
(
str
(
list
(
DATASETS
.
keys
())))
,
type
=
str
,
default
=
'OpticDiscSeg'
)
...
...
@@ -80,14 +80,10 @@ def main(args):
if
env_info
[
'place'
]
==
'cuda'
and
fluid
.
is_compiled_with_cuda
()
\
else
fluid
.
CPUPlace
()
if
args
.
dataset
.
lower
()
==
'opticdiscseg'
:
dataset
=
OpticDiscSeg
elif
args
.
dataset
.
lower
()
==
'cityscapes'
:
dataset
=
Cityscapes
else
:
raise
Exception
(
"The --dataset set wrong. It should be one of ('OpticDiscSeg', 'Cityscapes')"
)
if
args
.
dataset
not
in
DATASETS
:
raise
Exception
(
'--dataset is invalid. it should be one of {}'
.
format
(
str
(
list
(
DATASETS
.
keys
()))))
dataset
=
DATASETS
[
args
.
dataset
]
with
fluid
.
dygraph
.
guard
(
places
):
eval_transforms
=
T
.
Compose
([
T
.
Resize
(
args
.
input_size
),
T
.
Normalize
()])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录