Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
38ac17f1
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,体验更适合开发者的 AI 搜索 >>
提交
38ac17f1
编写于
4月 24, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use logger and config in app.py
上级
52ff12a0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
62 deletion
+66
-62
labelme/__init__.py
labelme/__init__.py
+9
-0
labelme/app.py
labelme/app.py
+7
-46
labelme/canvas.py
labelme/canvas.py
+1
-9
labelme/config/__init__.py
labelme/config/__init__.py
+44
-3
labelme/labelDialog.py
labelme/labelDialog.py
+2
-2
labelme/shape.py
labelme/shape.py
+3
-2
未找到文件。
labelme/__init__.py
浏览文件 @
38ac17f1
# flake8: noqa
import
logging
__appname__
=
'labelme'
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
__appname__
)
from
labelme
import
testing
from
labelme
import
utils
labelme/app.py
浏览文件 @
38ac17f1
import
argparse
import
functools
import
logging
import
os.path
import
re
import
sys
...
...
@@ -12,13 +11,13 @@ from qtpy import QtCore
from
qtpy.QtCore
import
Qt
from
qtpy
import
QtGui
from
qtpy
import
QtWidgets
import
yaml
QT5
=
QT_VERSION
[
0
]
==
'5'
from
labelme
import
__appname__
from
labelme.canvas
import
Canvas
from
labelme.colorDialog
import
ColorDialog
from
labelme.config
import
defaul
t_config
from
labelme.config
import
ge
t_config
from
labelme.labelDialog
import
LabelDialog
from
labelme.labelFile
import
LabelFile
from
labelme.labelFile
import
LabelFileError
...
...
@@ -27,6 +26,7 @@ from labelme.lib import fmtShortcut
from
labelme.lib
import
newAction
from
labelme.lib
import
newIcon
from
labelme.lib
import
struct
from
labelme
import
logger
from
labelme.shape
import
DEFAULT_FILL_COLOR
from
labelme.shape
import
DEFAULT_LINE_COLOR
from
labelme.shape
import
Shape
...
...
@@ -34,13 +34,6 @@ from labelme.toolBar import ToolBar
from
labelme.zoomWidget
import
ZoomWidget
__appname__
=
'labelme'
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logger
=
logging
.
getLogger
(
__appname__
)
# FIXME
# - [medium] Set max zoom value to something big enough for FitWidth/Window
...
...
@@ -133,10 +126,13 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
def
__init__
(
self
,
filename
=
None
,
output
=
None
,
store_data
=
True
,
labels
=
None
,
sort_labels
=
True
,
auto_save
=
False
,
validate_label
=
None
):
validate_label
=
None
,
config
=
None
):
super
(
MainWindow
,
self
).
__init__
()
self
.
setWindowTitle
(
__appname__
)
if
config
is
None
:
config
=
get_config
()
# Whether we need to save or not.
self
.
dirty
=
False
...
...
@@ -225,8 +221,6 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
QtWidgets
.
QDockWidget
.
DockWidgetFloatable
)
self
.
dock
.
setFeatures
(
self
.
dock
.
features
()
^
self
.
dockFeatures
)
config
=
self
.
getConfig
()
# Actions
action
=
functools
.
partial
(
newAction
,
self
)
shortcuts
=
config
[
'shortcuts'
]
...
...
@@ -472,39 +466,6 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
# Support Functions
def
getConfig
(
self
):
# shortcuts for actions
home
=
os
.
path
.
expanduser
(
'~'
)
config_file
=
os
.
path
.
join
(
home
,
'.labelmerc'
)
# default config
config
=
default_config
.
copy
()
def
update_dict
(
target_dict
,
new_dict
):
for
key
,
value
in
new_dict
.
items
():
if
key
not
in
target_dict
:
logger
.
warn
(
'Skipping unexpected key in config: {}'
.
format
(
key
))
continue
if
isinstance
(
target_dict
[
key
],
dict
)
and
\
isinstance
(
value
,
dict
):
update_dict
(
target_dict
[
key
],
value
)
else
:
target_dict
[
key
]
=
value
if
os
.
path
.
exists
(
config_file
):
user_config
=
yaml
.
load
(
open
(
config_file
))
or
{}
update_dict
(
config
,
user_config
)
# save config
try
:
yaml
.
safe_dump
(
config
,
open
(
config_file
,
'w'
),
default_flow_style
=
False
)
except
Exception
:
warnings
.
warn
(
'Failed to save config: {}'
.
format
(
config_file
))
return
config
def
noShapes
(
self
):
return
not
self
.
labelList
.
itemsToShapes
...
...
labelme/canvas.py
浏览文件 @
38ac17f1
from
__future__
import
print_function
import
sys
from
qtpy
import
QT_VERSION
from
qtpy
import
QtCore
from
qtpy
import
QtGui
...
...
@@ -220,11 +216,7 @@ class Canvas(QtWidgets.QWidget):
if
ev
.
button
()
==
QtCore
.
Qt
.
LeftButton
:
if
self
.
drawing
():
if
self
.
current
:
try
:
self
.
current
.
addPoint
(
self
.
line
[
1
])
except
Exception
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
return
self
.
current
.
addPoint
(
self
.
line
[
1
])
self
.
line
[
0
]
=
self
.
current
[
-
1
]
if
self
.
current
.
isClosed
():
self
.
finalise
()
...
...
labelme/config/__init__.py
浏览文件 @
38ac17f1
import
os
import
os.path
as
osp
import
yaml
from
labelme
import
logger
here
=
osp
.
dirname
(
osp
.
abspath
(
__file__
))
config_file
=
osp
.
join
(
here
,
'default_config.yaml'
)
default_config
=
yaml
.
load
(
open
(
config_file
))
del
here
,
config_file
def
update_dict
(
target_dict
,
new_dict
):
for
key
,
value
in
new_dict
.
items
():
if
key
not
in
target_dict
:
logger
.
warn
(
'Skipping unexpected key in config: {}'
.
format
(
key
))
continue
if
isinstance
(
target_dict
[
key
],
dict
)
and
\
isinstance
(
value
,
dict
):
update_dict
(
target_dict
[
key
],
value
)
else
:
target_dict
[
key
]
=
value
def
get_default_config
():
config_file
=
osp
.
join
(
here
,
'default_config.yaml'
)
config
=
yaml
.
load
(
open
(
config_file
))
return
config
def
get_config
():
# default config
config
=
get_default_config
()
# shortcuts for actions
home
=
os
.
path
.
expanduser
(
'~'
)
config_file
=
os
.
path
.
join
(
home
,
'.labelmerc'
)
if
os
.
path
.
exists
(
config_file
):
user_config
=
yaml
.
load
(
open
(
config_file
))
or
{}
update_dict
(
config
,
user_config
)
# save config
try
:
yaml
.
safe_dump
(
config
,
open
(
config_file
,
'w'
),
default_flow_style
=
False
)
except
Exception
:
logger
.
warn
(
'Failed to save config: {}'
.
format
(
config_file
))
return
config
labelme/labelDialog.py
浏览文件 @
38ac17f1
...
...
@@ -5,8 +5,8 @@ from qtpy import QtWidgets
QT5
=
QT_VERSION
[
0
]
==
'5'
from
.lib
import
labelValidator
from
.lib
import
newIcon
from
labelme
.lib
import
labelValidator
from
labelme
.lib
import
newIcon
# TODO(unknown):
...
...
labelme/shape.py
浏览文件 @
38ac17f1
from
qtpy
import
QtGui
from
.lib
import
distance
from
labelme.lib
import
distance
from
labelme
import
logger
# TODO(unknown):
...
...
@@ -54,7 +55,7 @@ class Shape(object):
self
.
line_color
=
line_color
def
close
(
self
):
assert
len
(
self
.
points
)
>
2
,
'Polygon should be created with points >2'
logger
.
warn
(
'Polygon should be created with points >2'
)
self
.
_closed
=
True
def
addPoint
(
self
,
point
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录