Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
a7ba98a8
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看板
未验证
提交
a7ba98a8
编写于
4月 21, 2020
作者:
L
LutaoChu
提交者:
GitHub
4月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix label tools bug (#224)
上级
cd51ed6c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
21 deletion
+19
-21
pdseg/tools/jingling2seg.py
pdseg/tools/jingling2seg.py
+14
-12
pdseg/tools/labelme2seg.py
pdseg/tools/labelme2seg.py
+5
-9
未找到文件。
pdseg/tools/jingling2seg.py
浏览文件 @
a7ba98a8
...
...
@@ -17,10 +17,8 @@ from gray2pseudo_color import get_color_map_list
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'input_dir'
,
help
=
'input annotated directory'
)
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'input_dir'
,
help
=
'input annotated directory'
)
return
parser
.
parse_args
()
...
...
@@ -62,8 +60,7 @@ def main(args):
print
(
'Generating dataset from:'
,
label_file
)
with
open
(
label_file
)
as
f
:
base
=
osp
.
splitext
(
osp
.
basename
(
label_file
))[
0
]
out_png_file
=
osp
.
join
(
output_dir
,
base
+
'.png'
)
out_png_file
=
osp
.
join
(
output_dir
,
base
+
'.png'
)
data
=
json
.
load
(
f
)
...
...
@@ -77,16 +74,22 @@ def main(args):
# convert jingling format to labelme format
points
=
[]
for
i
in
range
(
1
,
int
(
len
(
polygon
)
/
2
)
+
1
):
points
.
append
([
polygon
[
'x'
+
str
(
i
)],
polygon
[
'y'
+
str
(
i
)]])
shape
=
{
'label'
:
name
,
'points'
:
points
,
'shape_type'
:
'polygon'
}
points
.
append
(
[
polygon
[
'x'
+
str
(
i
)],
polygon
[
'y'
+
str
(
i
)]])
shape
=
{
'label'
:
name
,
'points'
:
points
,
'shape_type'
:
'polygon'
}
data_shapes
.
append
(
shape
)
if
'size'
not
in
data
:
continue
data_size
=
data
[
'size'
]
img_shape
=
(
data_size
[
'height'
],
data_size
[
'width'
],
data_size
[
'depth'
])
img_shape
=
(
data_size
[
'height'
],
data_size
[
'width'
],
data_size
[
'depth'
])
lbl
=
labelme
.
utils
.
shapes_to_label
(
lbl
,
_
=
labelme
.
utils
.
shapes_to_label
(
img_shape
=
img_shape
,
shapes
=
data_shapes
,
label_name_to_value
=
class_name_to_id
,
...
...
@@ -102,8 +105,7 @@ def main(args):
else
:
raise
ValueError
(
'[%s] Cannot save the pixel-wise class label as PNG. '
'Please consider using the .npy format.'
%
out_png_file
)
'Please consider using the .npy format.'
%
out_png_file
)
if
__name__
==
'__main__'
:
...
...
pdseg/tools/labelme2seg.py
浏览文件 @
a7ba98a8
...
...
@@ -17,10 +17,8 @@ from gray2pseudo_color import get_color_map_list
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'input_dir'
,
help
=
'input annotated directory'
)
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'input_dir'
,
help
=
'input annotated directory'
)
return
parser
.
parse_args
()
...
...
@@ -61,15 +59,14 @@ def main(args):
print
(
'Generating dataset from:'
,
label_file
)
with
open
(
label_file
)
as
f
:
base
=
osp
.
splitext
(
osp
.
basename
(
label_file
))[
0
]
out_png_file
=
osp
.
join
(
output_dir
,
base
+
'.png'
)
out_png_file
=
osp
.
join
(
output_dir
,
base
+
'.png'
)
data
=
json
.
load
(
f
)
img_file
=
osp
.
join
(
osp
.
dirname
(
label_file
),
data
[
'imagePath'
])
img
=
np
.
asarray
(
PIL
.
Image
.
open
(
img_file
))
lbl
=
labelme
.
utils
.
shapes_to_label
(
lbl
,
_
=
labelme
.
utils
.
shapes_to_label
(
img_shape
=
img
.
shape
,
shapes
=
data
[
'shapes'
],
label_name_to_value
=
class_name_to_id
,
...
...
@@ -85,8 +82,7 @@ def main(args):
else
:
raise
ValueError
(
'[%s] Cannot save the pixel-wise class label as PNG. '
'Please consider using the .npy format.'
%
out_png_file
)
'Please consider using the .npy format.'
%
out_png_file
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录