Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
4cdc97c3
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
285
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看板
提交
4cdc97c3
编写于
8月 07, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update citescapes dataset
上级
58dd74fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
36 deletion
+41
-36
dygraph/datasets/cityscapes.py
dygraph/datasets/cityscapes.py
+39
-36
dygraph/tools/conver_cityscapes.py
dygraph/tools/conver_cityscapes.py
+2
-0
未找到文件。
dygraph/datasets/cityscapes.py
浏览文件 @
4cdc97c3
...
@@ -13,58 +13,61 @@
...
@@ -13,58 +13,61 @@
# limitations under the License.
# limitations under the License.
import
os
import
os
import
glob
from
.dataset
import
Dataset
from
.dataset
import
Dataset
from
utils.download
import
download_file_and_uncompress
DATA_HOME
=
os
.
path
.
expanduser
(
'~/.cache/paddle/dataset'
)
URL
=
"https://paddleseg.bj.bcebos.com/dataset/cityscapes.tar"
class
Cityscapes
(
Dataset
):
class
Cityscapes
(
Dataset
):
def
__init__
(
self
,
"""Cityscapes dataset `https://www.cityscapes-dataset.com/`.
data_dir
=
None
,
The folder structure is as follow:
transforms
=
None
,
cityscapes
mode
=
'train'
,
|
download
=
True
):
|--leftImg8bit
| |--train
| |--val
| |--test
|
|--gtFine
| |--train
| |--val
| |--test
Make sure there are **labelTrainIds.png in gtFine directory. If not, please run the conver_cityscapes.py in tools.
Args:
data_dir: Cityscapes dataset directory.
mode: Which part of dataset to use. it is one of ('train', 'val', 'test'). Default: 'train'.
transforms: Transforms for image.
"""
def
__init__
(
self
,
data_dir
,
transforms
=
None
,
mode
=
'train'
):
self
.
data_dir
=
data_dir
self
.
data_dir
=
data_dir
self
.
transforms
=
transforms
self
.
transforms
=
transforms
self
.
file_list
=
list
()
self
.
file_list
=
list
()
self
.
mode
=
mode
self
.
mode
=
mode
self
.
num_classes
=
19
self
.
num_classes
=
19
if
mode
.
lower
()
not
in
[
'train'
,
'
e
val'
,
'test'
]:
if
mode
.
lower
()
not
in
[
'train'
,
'val'
,
'test'
]:
raise
Exception
(
raise
Exception
(
"mode should be 'train', '
e
val' or 'test', but got {}."
.
format
(
"mode should be 'train', 'val' or 'test', but got {}."
.
format
(
mode
))
mode
))
if
self
.
transforms
is
None
:
if
self
.
transforms
is
None
:
raise
Exception
(
"transforms is necessary, but it is None."
)
raise
Exception
(
"transforms is necessary, but it is None."
)
if
self
.
data_dir
is
None
:
img_dir
=
os
.
path
.
join
(
self
.
data_dir
,
'leftImg8bit'
)
if
not
download
:
grt_dir
=
os
.
path
.
join
(
self
.
data_dir
,
'gtFine'
)
raise
Exception
(
"data_file not set and auto download disabled."
)
if
not
os
.
path
.
isdir
(
self
.
data_dir
)
or
not
os
.
path
.
isdir
(
self
.
data_dir
=
download_file_and_uncompress
(
img_dir
)
or
not
os
.
path
.
isdir
(
grt_dir
):
url
=
URL
,
savepath
=
DATA_HOME
,
extrapath
=
DATA_HOME
)
raise
Exception
(
"The dataset is not Found or the folder structure is nonconfoumance."
)
if
mode
==
'train'
:
grt_files
=
sorted
(
file_list
=
os
.
path
.
join
(
self
.
data_dir
,
'train.list'
)
glob
.
glob
(
elif
mode
==
'eval'
:
os
.
path
.
join
(
grt_dir
,
mode
,
'*'
,
'*_gtFine_labelTrainIds.png'
)))
file_list
=
os
.
path
.
join
(
self
.
data_dir
,
'val.list'
)
img_files
=
sorted
(
else
:
glob
.
glob
(
os
.
path
.
join
(
img_dir
,
mode
,
'*'
,
'*_leftImg8bit.png'
)))
file_list
=
os
.
path
.
join
(
self
.
data_dir
,
'test.list'
)
with
open
(
file_list
,
'r'
)
as
f
:
self
.
file_list
=
[[
img_path
,
grt_path
]
for
line
in
f
:
for
img_path
,
grt_path
in
zip
(
img_files
,
grt_files
)]
items
=
line
.
strip
().
split
()
if
len
(
items
)
!=
2
:
if
mode
==
'train'
or
mode
==
'eval'
:
raise
Exception
(
"File list format incorrect! It should be"
" image_name label_name
\\
n"
)
image_path
=
os
.
path
.
join
(
self
.
data_dir
,
items
[
0
])
grt_path
=
None
else
:
image_path
=
os
.
path
.
join
(
self
.
data_dir
,
items
[
0
])
grt_path
=
os
.
path
.
join
(
self
.
data_dir
,
items
[
1
])
self
.
file_list
.
append
([
image_path
,
grt_path
])
dygraph/tools/conver_cityscapes.py
浏览文件 @
4cdc97c3
...
@@ -21,10 +21,12 @@ cityscapes
...
@@ -21,10 +21,12 @@ cityscapes
|--leftImg8bit
|--leftImg8bit
| |--train
| |--train
| |--val
| |--val
| |--test
|
|
|--gtFine
|--gtFine
| |--train
| |--train
| |--val
| |--val
| |--test
"""
"""
import
os
import
os
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录