Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
e0584078
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 搜索 >>
提交
e0584078
编写于
2月 04, 2020
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add color circle to the unique label list
上级
5085cead
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
75 addition
and
44 deletion
+75
-44
labelme/app.py
labelme/app.py
+41
-41
labelme/config/default_config.yaml
labelme/config/default_config.yaml
+0
-1
labelme/widgets/__init__.py
labelme/widgets/__init__.py
+2
-2
labelme/widgets/unique_label_qlist_widget.py
labelme/widgets/unique_label_qlist_widget.py
+32
-0
未找到文件。
labelme/app.py
浏览文件 @
e0584078
...
...
@@ -24,10 +24,10 @@ from labelme.logger import logger
from
labelme.shape
import
Shape
from
labelme.widgets
import
Canvas
from
labelme.widgets
import
ColorDialog
from
labelme.widgets
import
EscapableQListWidget
from
labelme.widgets
import
LabelDialog
from
labelme.widgets
import
LabelQListWidget
from
labelme.widgets
import
ToolBar
from
labelme.widgets
import
UniqueLabelQListWidget
from
labelme.widgets
import
ZoomWidget
...
...
@@ -115,12 +115,16 @@ class MainWindow(QtWidgets.QMainWindow):
self
.
shape_dock
.
setObjectName
(
'Labels'
)
self
.
shape_dock
.
setWidget
(
self
.
labelList
)
self
.
uniqLabelList
=
Escapable
QListWidget
()
self
.
uniqLabelList
=
UniqueLabel
QListWidget
()
self
.
uniqLabelList
.
setToolTip
(
self
.
tr
(
"Select label to start annotating for it. "
"Press 'Esc' to deselect."
))
if
self
.
_config
[
'labels'
]:
self
.
uniqLabelList
.
addItems
(
self
.
_config
[
'labels'
])
for
label
in
self
.
_config
[
'labels'
]:
item
=
self
.
uniqLabelList
.
createItemFromLabel
(
label
)
self
.
uniqLabelList
.
addItem
(
item
)
rgb
=
self
.
_get_rgb_by_label
(
label
)
self
.
uniqLabelList
.
setItemLabel
(
item
,
label
,
rgb
)
self
.
label_dock
=
QtWidgets
.
QDockWidget
(
self
.
tr
(
u
'Label List'
),
self
)
self
.
label_dock
.
setObjectName
(
u
'Label List'
)
self
.
label_dock
.
setWidget
(
self
.
uniqLabelList
)
...
...
@@ -877,7 +881,7 @@ class MainWindow(QtWidgets.QMainWindow):
return
True
for
i
in
range
(
self
.
uniqLabelList
.
count
()):
label_i
=
self
.
uniqLabelList
.
item
(
i
).
text
(
)
label_i
=
self
.
uniqLabelList
.
item
(
i
).
data
(
Qt
.
UserRole
)
if
self
.
_config
[
'validate_label'
]
in
[
'exact'
]:
if
label_i
==
label
:
return
True
...
...
@@ -917,8 +921,10 @@ class MainWindow(QtWidgets.QMainWindow):
else
:
item
.
setText
(
'{} ({})'
.
format
(
shape
.
label
,
shape
.
group_id
))
self
.
setDirty
()
if
not
self
.
uniqLabelList
.
findItems
(
shape
.
label
,
Qt
.
MatchExactly
):
self
.
uniqLabelList
.
addItem
(
shape
.
label
)
if
not
self
.
uniqLabelList
.
findItemsByLabel
(
shape
.
label
):
item
=
QtWidgets
.
QListWidgetItem
()
item
.
setData
(
role
=
Qt
.
UserRole
,
value
=
shape
.
label
)
self
.
uniqLabelList
.
addItem
(
item
)
def
fileSearchChanged
(
self
):
self
.
importDirImages
(
...
...
@@ -975,38 +981,42 @@ class MainWindow(QtWidgets.QMainWindow):
qlabel
.
setAlignment
(
QtCore
.
Qt
.
AlignBottom
)
item
.
setSizeHint
(
qlabel
.
sizeHint
())
self
.
labelList
.
setItemWidget
(
item
,
qlabel
)
if
not
self
.
uniqLabelList
.
findItems
(
shape
.
label
,
Qt
.
MatchExactly
):
self
.
uniqLabelList
.
addItem
(
shape
.
label
)
if
not
self
.
uniqLabelList
.
findItemsByLabel
(
shape
.
label
):
item
=
self
.
uniqLabelList
.
createItemFromLabel
(
shape
.
label
)
self
.
uniqLabelList
.
addItem
(
item
)
rgb
=
self
.
_get_rgb_by_label
(
shape
.
label
)
self
.
uniqLabelList
.
setItemLabel
(
item
,
shape
.
label
,
rgb
)
self
.
labelDialog
.
addLabelHistory
(
shape
.
label
)
for
action
in
self
.
actions
.
onShapesPresent
:
action
.
setEnabled
(
True
)
if
self
.
_config
[
'shape_color'
]
==
'auto'
:
r
,
g
,
b
=
self
.
_get_rgb_by_label
(
shape
.
label
)
elif
(
self
.
_config
[
'shape_color'
]
==
'manual'
and
self
.
_config
[
'label_colors'
]
and
shape
.
label
in
self
.
_config
[
'label_colors'
]):
r
,
g
,
b
=
self
.
_config
[
'label_colors'
][
shape
.
label
]
elif
self
.
_config
[
'default_shape_color'
]:
r
,
g
,
b
=
self
.
_config
[
'default_shape_color'
]
else
:
rgb
=
self
.
_get_rgb_by_label
(
shape
.
label
)
if
rgb
is
None
:
return
qlabel
.
setText
(
'{} <font color="#{:02x}{:02x}{:02x}">●</font>'
.
format
(
text
,
r
,
g
,
b
)
.
format
(
text
,
*
rg
b
)
)
shape
.
line_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
vertex_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
line_color
=
QtGui
.
QColor
(
*
rg
b
)
shape
.
vertex_fill_color
=
QtGui
.
QColor
(
*
rg
b
)
shape
.
hvertex_fill_color
=
QtGui
.
QColor
(
255
,
255
,
255
)
shape
.
fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
,
128
)
shape
.
fill_color
=
QtGui
.
QColor
(
*
rg
b
,
128
)
shape
.
select_line_color
=
QtGui
.
QColor
(
255
,
255
,
255
)
shape
.
select_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
,
155
)
shape
.
select_fill_color
=
QtGui
.
QColor
(
*
rg
b
,
155
)
def
_get_rgb_by_label
(
self
,
label
):
item
=
self
.
uniqLabelList
.
findItems
(
label
,
Qt
.
MatchExactly
)[
0
]
label_id
=
self
.
uniqLabelList
.
indexFromItem
(
item
).
row
()
+
1
label_id
+=
self
.
_config
[
'shift_auto_shape_color'
]
return
LABEL_COLORMAP
[
label_id
%
len
(
LABEL_COLORMAP
)]
if
self
.
_config
[
'shape_color'
]
==
'auto'
:
item
=
self
.
uniqLabelList
.
findItemsByLabel
(
label
)[
0
]
label_id
=
self
.
uniqLabelList
.
indexFromItem
(
item
).
row
()
+
1
label_id
+=
self
.
_config
[
'shift_auto_shape_color'
]
return
LABEL_COLORMAP
[
label_id
%
len
(
LABEL_COLORMAP
)]
elif
(
self
.
_config
[
'shape_color'
]
==
'manual'
and
self
.
_config
[
'label_colors'
]
and
label
in
self
.
_config
[
'label_colors'
]):
return
self
.
_config
[
'label_colors'
][
label
]
elif
self
.
_config
[
'default_shape_color'
]:
return
self
.
_config
[
'default_shape_color'
]
def
remLabels
(
self
,
shapes
):
for
shape
in
shapes
:
...
...
@@ -1145,25 +1155,15 @@ class MainWindow(QtWidgets.QMainWindow):
"""
items
=
self
.
uniqLabelList
.
selectedItems
()
text
=
None
if
items
:
text
=
items
[
0
].
data
(
Qt
.
UserRole
)
flags
=
{}
group_id
=
None
if
items
:
text
=
items
[
0
].
text
()
if
self
.
_config
[
'display_label_popup'
]
or
not
text
:
# instance label auto increment
if
self
.
_config
[
'instance_label_auto_increment'
]:
previous_label
=
self
.
labelDialog
.
edit
.
text
()
split
=
previous_label
.
split
(
'-'
)
if
len
(
split
)
>
1
and
split
[
-
1
].
isdigit
():
split
[
-
1
]
=
str
(
int
(
split
[
-
1
])
+
1
)
instance_text
=
'-'
.
join
(
split
)
else
:
instance_text
=
previous_label
if
instance_text
!=
''
:
text
=
instance_text
previous_text
=
self
.
labelDialog
.
edit
.
text
()
text
,
flags
,
group_id
=
self
.
labelDialog
.
popUp
(
text
)
if
text
is
None
:
self
.
labelDialog
.
edit
.
setText
(
previous_
label
)
if
not
text
:
self
.
labelDialog
.
edit
.
setText
(
previous_
text
)
if
text
and
not
self
.
validateLabel
(
text
):
self
.
errorMessage
(
...
...
labelme/config/default_config.yaml
浏览文件 @
e0584078
auto_save
:
false
display_label_popup
:
true
instance_label_auto_increment
:
true
store_data
:
true
keep_prev
:
false
keep_prev_scale
:
false
...
...
labelme/widgets/__init__.py
浏览文件 @
e0584078
...
...
@@ -4,8 +4,6 @@ from .canvas import Canvas
from
.color_dialog
import
ColorDialog
from
.escapable_qlist_widget
import
EscapableQListWidget
from
.label_dialog
import
LabelDialog
from
.label_dialog
import
LabelQLineEdit
...
...
@@ -13,4 +11,6 @@ from .label_qlist_widget import LabelQListWidget
from
.tool_bar
import
ToolBar
from
.unique_label_qlist_widget
import
UniqueLabelQListWidget
from
.zoom_widget
import
ZoomWidget
labelme/widgets/unique_label_qlist_widget.py
0 → 100644
浏览文件 @
e0584078
from
qtpy.QtCore
import
Qt
from
qtpy
import
QtWidgets
from
.escapable_qlist_widget
import
EscapableQListWidget
class
UniqueLabelQListWidget
(
EscapableQListWidget
):
def
findItemsByLabel
(
self
,
label
):
items
=
[]
for
row
in
range
(
self
.
count
()):
item
=
self
.
item
(
row
)
if
item
.
data
(
Qt
.
UserRole
)
==
label
:
items
.
append
(
item
)
return
items
def
createItemFromLabel
(
self
,
label
):
item
=
QtWidgets
.
QListWidgetItem
()
item
.
setData
(
Qt
.
UserRole
,
label
)
return
item
def
setItemLabel
(
self
,
item
,
label
,
color
):
qlabel
=
QtWidgets
.
QLabel
()
qlabel
.
setText
(
'{} <font color="#{:02x}{:02x}{:02x}">●</font>'
.
format
(
label
,
*
color
)
)
qlabel
.
setAlignment
(
Qt
.
AlignBottom
)
item
.
setSizeHint
(
qlabel
.
sizeHint
())
self
.
setItemWidget
(
item
,
qlabel
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录