Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
c88d3e9d
L
labelme
项目概览
不会修仙的道士
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
labelme
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c88d3e9d
编写于
4月 25, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add labelme_draw_label_png
上级
4f2f8454
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
2 deletion
+49
-2
examples/tutorial/.readme/draw_label_png.jpg
examples/tutorial/.readme/draw_label_png.jpg
+0
-0
examples/tutorial/README.md
examples/tutorial/README.md
+8
-0
labelme/cli/__init__.py
labelme/cli/__init__.py
+1
-0
labelme/cli/draw_label_png.py
labelme/cli/draw_label_png.py
+34
-0
labelme/utils.py
labelme/utils.py
+5
-2
setup.py
setup.py
+1
-0
未找到文件。
examples/tutorial/.readme/draw_label_png.jpg
0 → 100644
浏览文件 @
c88d3e9d
43.1 KB
examples/tutorial/README.md
浏览文件 @
c88d3e9d
...
@@ -56,3 +56,11 @@ array([0, 1, 2, 3], dtype=int32)
...
@@ -56,3 +56,11 @@ array([0, 1, 2, 3], dtype=int32)
>>>
lbl
.
shape
>>>
lbl
.
shape
(
907
,
1210
)
(
907
,
1210
)
```
```
Also, you can see the label PNG file by:
```
python
labelme_draw_label_png
apc2016_obj3_json
/
label
.
png
```
<img
src=
".readme/draw_label_png.jpg"
width=
"35%"
/>
labelme/cli/__init__.py
浏览文件 @
c88d3e9d
# flake8: noqa
# flake8: noqa
from
.
import
draw_json
from
.
import
draw_json
from
.
import
draw_label_png
from
.
import
json_to_dataset
from
.
import
json_to_dataset
from
.
import
on_docker
from
.
import
on_docker
labelme/cli/draw_label_png.py
0 → 100644
浏览文件 @
c88d3e9d
import
argparse
import
logging
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
PIL.Image
from
labelme
import
utils
def
main
():
logger
=
logging
.
Logger
(
'labelme'
)
logger
.
setLevel
(
logging
.
INFO
)
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'label_png'
,
help
=
'label PNG file'
)
args
=
parser
.
parse_args
()
lbl
=
np
.
asarray
(
PIL
.
Image
.
open
(
args
.
label_png
))
if
lbl
.
dtype
!=
np
.
int32
:
logger
.
warn
(
'We recomment numpy.int32 for the label, but it has: {}'
.
format
(
lbl
.
dtype
))
logger
.
info
(
'label shape: {}'
.
format
(
lbl
.
shape
))
logger
.
info
(
'unique label values: {}'
.
format
(
np
.
unique
(
lbl
)))
lbl_viz
=
utils
.
draw_label
(
lbl
)
plt
.
imshow
(
lbl_viz
)
plt
.
show
()
if
__name__
==
'__main__'
:
main
()
labelme/utils.py
浏览文件 @
c88d3e9d
...
@@ -86,7 +86,7 @@ def polygons_to_mask(img_shape, polygons):
...
@@ -86,7 +86,7 @@ def polygons_to_mask(img_shape, polygons):
return
mask
return
mask
def
draw_label
(
label
,
img
,
label_names
,
colormap
=
None
):
def
draw_label
(
label
,
img
=
None
,
label_names
=
None
,
colormap
=
None
):
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
backend_org
=
plt
.
rcParams
[
'backend'
]
backend_org
=
plt
.
rcParams
[
'backend'
]
plt
.
switch_backend
(
'agg'
)
plt
.
switch_backend
(
'agg'
)
...
@@ -97,6 +97,9 @@ def draw_label(label, img, label_names, colormap=None):
...
@@ -97,6 +97,9 @@ def draw_label(label, img, label_names, colormap=None):
plt
.
gca
().
xaxis
.
set_major_locator
(
plt
.
NullLocator
())
plt
.
gca
().
xaxis
.
set_major_locator
(
plt
.
NullLocator
())
plt
.
gca
().
yaxis
.
set_major_locator
(
plt
.
NullLocator
())
plt
.
gca
().
yaxis
.
set_major_locator
(
plt
.
NullLocator
())
if
label_names
is
None
:
label_names
=
[
str
(
l
)
for
l
in
range
(
label
.
max
()
+
1
)]
if
colormap
is
None
:
if
colormap
is
None
:
colormap
=
label_colormap
(
len
(
label_names
))
colormap
=
label_colormap
(
len
(
label_names
))
...
@@ -124,7 +127,7 @@ def draw_label(label, img, label_names, colormap=None):
...
@@ -124,7 +127,7 @@ def draw_label(label, img, label_names, colormap=None):
plt
.
switch_backend
(
backend_org
)
plt
.
switch_backend
(
backend_org
)
out_size
=
(
img
.
shape
[
1
],
img
.
shape
[
0
])
out_size
=
(
label_viz
.
shape
[
1
],
label_viz
.
shape
[
0
])
out
=
PIL
.
Image
.
open
(
f
).
resize
(
out_size
,
PIL
.
Image
.
BILINEAR
).
convert
(
'RGB'
)
out
=
PIL
.
Image
.
open
(
f
).
resize
(
out_size
,
PIL
.
Image
.
BILINEAR
).
convert
(
'RGB'
)
out
=
np
.
asarray
(
out
)
out
=
np
.
asarray
(
out
)
return
out
return
out
...
...
setup.py
浏览文件 @
c88d3e9d
...
@@ -91,6 +91,7 @@ setup(
...
@@ -91,6 +91,7 @@ setup(
'console_scripts'
:
[
'console_scripts'
:
[
'labelme=labelme.app:main'
,
'labelme=labelme.app:main'
,
'labelme_draw_json=labelme.cli.draw_json:main'
,
'labelme_draw_json=labelme.cli.draw_json:main'
,
'labelme_draw_label_png=labelme.cli.draw_label_png:main'
,
'labelme_json_to_dataset=labelme.cli.json_to_dataset:main'
,
'labelme_json_to_dataset=labelme.cli.json_to_dataset:main'
,
'labelme_on_docker=labelme.cli.on_docker:main'
,
'labelme_on_docker=labelme.cli.on_docker:main'
,
],
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录