Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
27号BigBang
labelme
提交
109c39aa
L
labelme
项目概览
27号BigBang
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
6
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,体验更适合开发者的 AI 搜索 >>
提交
109c39aa
编写于
2月 06, 2020
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more tests with OpenDir
上级
e6d3bda1
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
82 addition
and
33 deletion
+82
-33
labelme/testing.py
labelme/testing.py
+10
-2
tests/labelme_tests/data/annotated/2011_000003.jpg
tests/labelme_tests/data/annotated/2011_000003.jpg
+1
-0
tests/labelme_tests/data/annotated/2011_000003.json
tests/labelme_tests/data/annotated/2011_000003.json
+1
-0
tests/labelme_tests/data/annotated/2011_000006.jpg
tests/labelme_tests/data/annotated/2011_000006.jpg
+1
-0
tests/labelme_tests/data/annotated/2011_000006.json
tests/labelme_tests/data/annotated/2011_000006.json
+1
-0
tests/labelme_tests/data/annotated/2011_000025.jpg
tests/labelme_tests/data/annotated/2011_000025.jpg
+1
-0
tests/labelme_tests/data/annotated/2011_000025.json
tests/labelme_tests/data/annotated/2011_000025.json
+1
-0
tests/labelme_tests/data/annotated_with_data/apc2016_obj3.jpg
...s/labelme_tests/data/annotated_with_data/apc2016_obj3.jpg
+1
-0
tests/labelme_tests/data/annotated_with_data/apc2016_obj3.json
.../labelme_tests/data/annotated_with_data/apc2016_obj3.json
+1
-0
tests/labelme_tests/data/apc2016_obj3.jpg
tests/labelme_tests/data/apc2016_obj3.jpg
+0
-1
tests/labelme_tests/data/apc2016_obj3.json
tests/labelme_tests/data/apc2016_obj3.json
+0
-1
tests/labelme_tests/data/raw/2011_000003.jpg
tests/labelme_tests/data/raw/2011_000003.jpg
+1
-0
tests/labelme_tests/data/raw/2011_000006.jpg
tests/labelme_tests/data/raw/2011_000006.jpg
+1
-0
tests/labelme_tests/data/raw/2011_000025.jpg
tests/labelme_tests/data/raw/2011_000025.jpg
+1
-0
tests/labelme_tests/test_app.py
tests/labelme_tests/test_app.py
+58
-26
tests/labelme_tests/utils_tests/test_image.py
tests/labelme_tests/utils_tests/test_image.py
+2
-2
tests/labelme_tests/utils_tests/util.py
tests/labelme_tests/utils_tests/util.py
+1
-1
未找到文件。
labelme/testing.py
浏览文件 @
109c39aa
import
json
import
os.path
as
osp
import
imgviz
import
labelme.utils
...
...
@@ -12,10 +13,17 @@ def assert_labelfile_sanity(filename):
assert
'imagePath'
in
data
imageData
=
data
.
get
(
'imageData'
,
None
)
if
imageData
is
None
:
assert
osp
.
exists
(
data
[
'imagePath'
])
img
=
labelme
.
utils
.
img_b64_to_arr
(
imageData
)
parent_dir
=
osp
.
dirname
(
filename
)
img_file
=
osp
.
join
(
parent_dir
,
data
[
'imagePath'
])
assert
osp
.
exists
(
img_file
)
img
=
imgviz
.
io
.
imread
(
img_file
)
else
:
img
=
labelme
.
utils
.
img_b64_to_arr
(
imageData
)
H
,
W
=
img
.
shape
[:
2
]
assert
H
==
data
[
'imageHeight'
]
assert
W
==
data
[
'imageWidth'
]
assert
'shapes'
in
data
for
shape
in
data
[
'shapes'
]:
assert
'label'
in
shape
...
...
tests/labelme_tests/data/annotated/2011_000003.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000003.jpg
\ No newline at end of file
tests/labelme_tests/data/annotated/2011_000003.json
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/
2011
_
000003
.json
\ No newline at end of file
tests/labelme_tests/data/annotated/2011_000006.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000006.jpg
\ No newline at end of file
tests/labelme_tests/data/annotated/2011_000006.json
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/
2011
_
000006
.json
\ No newline at end of file
tests/labelme_tests/data/annotated/2011_000025.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000025.jpg
\ No newline at end of file
tests/labelme_tests/data/annotated/2011_000025.json
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/
2011
_
000025
.json
\ No newline at end of file
tests/labelme_tests/data/annotated_with_data/apc2016_obj3.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/tutorial/apc2016_obj3.jpg
\ No newline at end of file
tests/labelme_tests/data/annotated_with_data/apc2016_obj3.json
0 → 120000
浏览文件 @
109c39aa
../../../../examples/tutorial/apc
2016
_obj
3
.json
\ No newline at end of file
tests/labelme_tests/data/apc2016_obj3.jpg
已删除
120000 → 0
浏览文件 @
e6d3bda1
../../../examples/tutorial/apc2016_obj3.jpg
\ No newline at end of file
tests/labelme_tests/data/apc2016_obj3.json
已删除
120000 → 0
浏览文件 @
e6d3bda1
../../../examples/tutorial/apc
2016
_obj
3
.json
\ No newline at end of file
tests/labelme_tests/data/raw/2011_000003.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000003.jpg
\ No newline at end of file
tests/labelme_tests/data/raw/2011_000006.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000006.jpg
\ No newline at end of file
tests/labelme_tests/data/raw/2011_000025.jpg
0 → 120000
浏览文件 @
109c39aa
../../../../examples/instance_segmentation/data_annotated/2011_000025.jpg
\ No newline at end of file
tests/labelme_tests/test_app.py
浏览文件 @
109c39aa
...
...
@@ -11,6 +11,16 @@ here = osp.dirname(osp.abspath(__file__))
data_dir
=
osp
.
join
(
here
,
'data'
)
def
_win_show_and_wait_imageData
(
qtbot
,
win
):
win
.
show
()
def
check_imageData
():
assert
hasattr
(
win
,
'imageData'
)
assert
win
.
imageData
is
not
None
qtbot
.
waitUntil
(
check_imageData
)
# wait for loadFile
def
test_MainWindow_open
(
qtbot
):
win
=
labelme
.
app
.
MainWindow
()
qtbot
.
addWidget
(
win
)
...
...
@@ -18,53 +28,75 @@ def test_MainWindow_open(qtbot):
win
.
close
()
def
test_MainWindow_open_json
(
qtbot
):
filename
=
osp
.
join
(
data_dir
,
'apc2016_obj3.json'
)
labelme
.
testing
.
assert_labelfile_sanity
(
filename
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
filename
)
def
test_MainWindow_open_img
(
qtbot
):
img_file
=
osp
.
join
(
data_dir
,
'raw/2011_000003.jpg'
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
img_file
)
qtbot
.
addWidget
(
win
)
win
.
show
(
)
_win_show_and_wait_imageData
(
qtbot
,
win
)
win
.
close
()
def
test_MainWindow_open_json
(
qtbot
):
json_files
=
[
osp
.
join
(
data_dir
,
'annotated_with_data/apc2016_obj3.json'
),
osp
.
join
(
data_dir
,
'annotated/2011_000003.json'
),
]
for
json_file
in
json_files
:
labelme
.
testing
.
assert_labelfile_sanity
(
json_file
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
json_file
)
qtbot
.
addWidget
(
win
)
_win_show_and_wait_imageData
(
qtbot
,
win
)
win
.
close
()
def
test_MainWindow_open_dir
(
qtbot
):
directory
=
osp
.
join
(
data_dir
,
'raw'
)
win
=
labelme
.
app
.
MainWindow
(
filename
=
directory
)
qtbot
.
addWidget
(
win
)
_win_show_and_wait_imageData
(
qtbot
,
win
)
return
win
def
test_MainWindow_openNextImg
(
qtbot
):
win
=
test_MainWindow_open_dir
(
qtbot
)
win
.
openNextImg
()
def
test_MainWindow_openPrevImg
(
qtbot
):
win
=
test_MainWindow_open_dir
(
qtbot
)
win
.
openNextImg
()
def
test_MainWindow_annotate_jpg
(
qtbot
):
tmp_dir
=
tempfile
.
mkdtemp
()
filename
=
osp
.
join
(
tmp_dir
,
'apc2016_obj3.jpg'
)
shutil
.
copy
(
osp
.
join
(
data_dir
,
'apc2016_obj3.jpg'
),
filename
)
output_file
=
osp
.
join
(
tmp_dir
,
'apc2016_obj3.json'
)
input_file
=
osp
.
join
(
data_dir
,
'raw/2011_000003.jpg'
)
out_file
=
osp
.
join
(
tmp_dir
,
'2011_000003.json'
)
config
=
labelme
.
config
.
get_default_config
()
win
=
labelme
.
app
.
MainWindow
(
config
=
config
,
filename
=
filenam
e
,
output_file
=
out
put
_file
,
filename
=
input_fil
e
,
output_file
=
out_file
,
)
qtbot
.
addWidget
(
win
)
win
.
show
()
def
check_imageData
():
assert
hasattr
(
win
,
'imageData'
)
assert
win
.
imageData
is
not
None
qtbot
.
waitUntil
(
check_imageData
)
# wait for loadFile
_win_show_and_wait_imageData
(
qtbot
,
win
)
label
=
'
shelf
'
label
=
'
whole
'
points
=
[
(
26
,
7
0
),
(
1
76
,
730
),
(
986
,
742
),
(
1184
,
102
),
(
100
,
10
0
),
(
1
00
,
238
),
(
400
,
238
),
(
400
,
100
),
]
shapes
=
[
dict
(
label
=
label
,
points
=
points
,
line_color
=
None
,
fill_color
=
None
,
shape_type
=
'polygon'
,
flags
=
{}
)]
win
.
loadLabels
(
shapes
)
win
.
saveFile
()
labelme
.
testing
.
assert_labelfile_sanity
(
output_file
)
labelme
.
testing
.
assert_labelfile_sanity
(
out_file
)
shutil
.
rmtree
(
tmp_dir
)
tests/labelme_tests/utils_tests/test_image.py
浏览文件 @
109c39aa
...
...
@@ -16,7 +16,7 @@ def test_img_b64_to_arr():
def
test_img_arr_to_b64
():
img_file
=
osp
.
join
(
data_dir
,
'apc2016_obj3.jpg'
)
img_file
=
osp
.
join
(
data_dir
,
'a
nnotated_with_data/a
pc2016_obj3.jpg'
)
img_arr
=
np
.
asarray
(
PIL
.
Image
.
open
(
img_file
))
img_b64
=
image_module
.
img_arr_to_b64
(
img_arr
)
img_arr2
=
image_module
.
img_b64_to_arr
(
img_b64
)
...
...
@@ -24,7 +24,7 @@ def test_img_arr_to_b64():
def
test_img_data_to_png_data
():
img_file
=
osp
.
join
(
data_dir
,
'apc2016_obj3.jpg'
)
img_file
=
osp
.
join
(
data_dir
,
'a
nnotated_with_data/a
pc2016_obj3.jpg'
)
with
open
(
img_file
,
'rb'
)
as
f
:
img_data
=
f
.
read
()
png_data
=
image_module
.
img_data_to_png_data
(
img_data
)
...
...
tests/labelme_tests/utils_tests/util.py
浏览文件 @
109c39aa
...
...
@@ -10,7 +10,7 @@ data_dir = osp.join(here, '../data')
def
get_img_and_data
():
json_file
=
osp
.
join
(
data_dir
,
'apc2016_obj3.json'
)
json_file
=
osp
.
join
(
data_dir
,
'a
nnotated_with_data/a
pc2016_obj3.json'
)
data
=
json
.
load
(
open
(
json_file
))
img_b64
=
data
[
'imageData'
]
img
=
image_module
.
img_b64_to_arr
(
img_b64
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录