Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
d771d5bd
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d771d5bd
编写于
8月 01, 2022
作者:
E
Evezerest
提交者:
GitHub
8月 01, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7044 from whjdark/dygraph
1、标签列表前显示序号;2、BBOX序号标签显示及时刷新修复
上级
27b8b9f3
31bf92c2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
77 addition
and
5 deletion
+77
-5
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+77
-5
未找到文件。
PPOCRLabel/PPOCRLabel.py
浏览文件 @
d771d5bd
...
...
@@ -28,7 +28,7 @@ from PyQt5.QtCore import QSize, Qt, QPoint, QByteArray, QTimer, QFileInfo, QPoin
from
PyQt5.QtGui
import
QImage
,
QCursor
,
QPixmap
,
QImageReader
from
PyQt5.QtWidgets
import
QMainWindow
,
QListWidget
,
QVBoxLayout
,
QToolButton
,
QHBoxLayout
,
QDockWidget
,
QWidget
,
\
QSlider
,
QGraphicsOpacityEffect
,
QMessageBox
,
QListView
,
QScrollArea
,
QWidgetAction
,
QApplication
,
QLabel
,
QGridLayout
,
\
QFileDialog
,
QListWidgetItem
,
QComboBox
,
QDialog
,
QAbstractItemView
QFileDialog
,
QListWidgetItem
,
QComboBox
,
QDialog
,
QAbstractItemView
,
QSizePolicy
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
...
...
@@ -227,6 +227,21 @@ class MainWindow(QMainWindow):
listLayout
.
addWidget
(
leftTopToolBoxContainer
)
# ================== Label List ==================
labelIndexListlBox
=
QHBoxLayout
()
# Create and add a widget for showing current label item index
self
.
indexList
=
QListWidget
()
self
.
indexList
.
setMaximumSize
(
40
,
16777215
)
# limit max width
self
.
indexList
.
setEditTriggers
(
QAbstractItemView
.
NoEditTriggers
)
# no editable
self
.
indexList
.
itemSelectionChanged
.
connect
(
self
.
indexSelectionChanged
)
self
.
indexList
.
setVerticalScrollBarPolicy
(
Qt
.
ScrollBarAlwaysOff
)
# no scroll Bar
self
.
indexListDock
=
QDockWidget
(
'No.'
,
self
)
self
.
indexListDock
.
setWidget
(
self
.
indexList
)
self
.
indexListDock
.
setFeatures
(
QDockWidget
.
NoDockWidgetFeatures
)
labelIndexListlBox
.
addWidget
(
self
.
indexListDock
,
1
)
# no margin between two boxes
labelIndexListlBox
.
setSpacing
(
0
)
# Create and add a widget for showing current label items
self
.
labelList
=
EditInList
()
labelListContainer
=
QWidget
()
...
...
@@ -240,7 +255,7 @@ class MainWindow(QMainWindow):
self
.
labelListDock
=
QDockWidget
(
self
.
labelListDockName
,
self
)
self
.
labelListDock
.
setWidget
(
self
.
labelList
)
self
.
labelListDock
.
setFeatures
(
QDockWidget
.
NoDockWidgetFeatures
)
l
istLayout
.
addWidget
(
self
.
labelListDock
)
l
abelIndexListlBox
.
addWidget
(
self
.
labelListDock
,
10
)
# label list is wider than index list
# enable labelList drag_drop to adjust bbox order
# 设置选择模式为单选
...
...
@@ -256,6 +271,17 @@ class MainWindow(QMainWindow):
# 触发放置
self
.
labelList
.
model
().
rowsMoved
.
connect
(
self
.
drag_drop_happened
)
labelIndexListContainer
=
QWidget
()
labelIndexListContainer
.
setLayout
(
labelIndexListlBox
)
listLayout
.
addWidget
(
labelIndexListContainer
)
# labelList indexList同步滚动
self
.
labelListBar
=
self
.
labelList
.
verticalScrollBar
()
self
.
indexListBar
=
self
.
indexList
.
verticalScrollBar
()
self
.
labelListBar
.
valueChanged
.
connect
(
self
.
move_scrollbar
)
self
.
indexListBar
.
valueChanged
.
connect
(
self
.
move_scrollbar
)
# ================== Detection Box ==================
self
.
BoxList
=
QListWidget
()
...
...
@@ -766,6 +792,7 @@ class MainWindow(QMainWindow):
self
.
shapesToItemsbox
.
clear
()
self
.
labelList
.
clear
()
self
.
BoxList
.
clear
()
self
.
indexList
.
clear
()
self
.
filePath
=
None
self
.
imageData
=
None
self
.
labelFile
=
None
...
...
@@ -1027,13 +1054,19 @@ class MainWindow(QMainWindow):
for
shape
in
self
.
canvas
.
selectedShapes
:
shape
.
selected
=
False
self
.
labelList
.
clearSelection
()
self
.
indexList
.
clearSelection
()
self
.
canvas
.
selectedShapes
=
selected_shapes
for
shape
in
self
.
canvas
.
selectedShapes
:
shape
.
selected
=
True
self
.
shapesToItems
[
shape
].
setSelected
(
True
)
self
.
shapesToItemsbox
[
shape
].
setSelected
(
True
)
index
=
self
.
labelList
.
indexFromItem
(
self
.
shapesToItems
[
shape
]).
row
()
self
.
indexList
.
item
(
index
).
setSelected
(
True
)
self
.
labelList
.
scrollToItem
(
self
.
currentItem
())
# QAbstractItemView.EnsureVisible
# map current label item to index item and select it
index
=
self
.
labelList
.
indexFromItem
(
self
.
currentItem
()).
row
()
self
.
indexList
.
scrollToItem
(
self
.
indexList
.
item
(
index
))
self
.
BoxList
.
scrollToItem
(
self
.
currentBox
())
if
self
.
kie_mode
:
...
...
@@ -1066,12 +1099,18 @@ class MainWindow(QMainWindow):
shape
.
paintIdx
=
self
.
displayIndexOption
.
isChecked
()
item
=
HashableQListWidgetItem
(
shape
.
label
)
item
.
setFlags
(
item
.
flags
()
|
Qt
.
ItemIsUserCheckable
)
item
.
setCheckState
(
Qt
.
Unchecked
)
if
shape
.
difficult
else
item
.
setCheckState
(
Qt
.
Checked
)
# current difficult checkbox is disenble
# item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
# item.setCheckState(Qt.Unchecked) if shape.difficult else item.setCheckState(Qt.Checked)
# Checked means difficult is False
# item.setBackground(generateColorByText(shape.label))
self
.
itemsToShapes
[
item
]
=
shape
self
.
shapesToItems
[
shape
]
=
item
# add current label item index before label string
current_index
=
QListWidgetItem
(
str
(
self
.
labelList
.
count
()))
current_index
.
setTextAlignment
(
Qt
.
AlignHCenter
)
self
.
indexList
.
addItem
(
current_index
)
self
.
labelList
.
addItem
(
item
)
# print('item in add label is ',[(p.x(), p.y()) for p in shape.points], shape.label)
...
...
@@ -1105,6 +1144,7 @@ class MainWindow(QMainWindow):
del
self
.
shapesToItemsbox
[
shape
]
del
self
.
itemsToShapesbox
[
item
]
self
.
updateComboBox
()
self
.
updateIndexList
()
def
loadLabels
(
self
,
shapes
):
s
=
[]
...
...
@@ -1156,6 +1196,13 @@ class MainWindow(QMainWindow):
# self.comboBox.update_items(uniqueTextList)
def
updateIndexList
(
self
):
self
.
indexList
.
clear
()
for
i
in
range
(
self
.
labelList
.
count
()):
string
=
QListWidgetItem
(
str
(
i
))
string
.
setTextAlignment
(
Qt
.
AlignHCenter
)
self
.
indexList
.
addItem
(
string
)
def
saveLabels
(
self
,
annotationFilePath
,
mode
=
'Auto'
):
# Mode is Auto means that labels will be loaded from self.result_dic totally, which is the output of ocr model
annotationFilePath
=
ustr
(
annotationFilePath
)
...
...
@@ -1211,6 +1258,10 @@ class MainWindow(QMainWindow):
# fix copy and delete
# self.shapeSelectionChanged(True)
def
move_scrollbar
(
self
,
value
):
self
.
labelListBar
.
setValue
(
value
)
self
.
indexListBar
.
setValue
(
value
)
def
labelSelectionChanged
(
self
):
if
self
.
_noSelectionSlot
:
return
...
...
@@ -1223,6 +1274,21 @@ class MainWindow(QMainWindow):
else
:
self
.
canvas
.
deSelectShape
()
def
indexSelectionChanged
(
self
):
if
self
.
_noSelectionSlot
:
return
if
self
.
canvas
.
editing
():
selected_shapes
=
[]
for
item
in
self
.
indexList
.
selectedItems
():
# map index item to label item
index
=
self
.
indexList
.
indexFromItem
(
item
).
row
()
item
=
self
.
labelList
.
item
(
index
)
selected_shapes
.
append
(
self
.
itemsToShapes
[
item
])
if
selected_shapes
:
self
.
canvas
.
selectShapes
(
selected_shapes
)
else
:
self
.
canvas
.
deSelectShape
()
def
boxSelectionChanged
(
self
):
if
self
.
_noSelectionSlot
:
# self.BoxList.scrollToItem(self.currentBox(), QAbstractItemView.PositionAtCenter)
...
...
@@ -1517,6 +1583,7 @@ class MainWindow(QMainWindow):
if
self
.
labelList
.
count
():
self
.
labelList
.
setCurrentItem
(
self
.
labelList
.
item
(
self
.
labelList
.
count
()
-
1
))
self
.
labelList
.
item
(
self
.
labelList
.
count
()
-
1
).
setSelected
(
True
)
self
.
indexList
.
item
(
self
.
labelList
.
count
()
-
1
).
setSelected
(
True
)
# show file list image count
select_indexes
=
self
.
fileListWidget
.
selectedIndexes
()
...
...
@@ -2015,12 +2082,14 @@ class MainWindow(QMainWindow):
for
shape
in
self
.
canvas
.
shapes
:
shape
.
paintLabel
=
self
.
displayLabelOption
.
isChecked
()
shape
.
paintIdx
=
self
.
displayIndexOption
.
isChecked
()
self
.
canvas
.
repaint
()
def
togglePaintIndexOption
(
self
):
self
.
displayLabelOption
.
setChecked
(
False
)
for
shape
in
self
.
canvas
.
shapes
:
shape
.
paintLabel
=
self
.
displayLabelOption
.
isChecked
()
shape
.
paintIdx
=
self
.
displayIndexOption
.
isChecked
()
self
.
canvas
.
repaint
()
def
toogleDrawSquare
(
self
):
self
.
canvas
.
setDrawingShapeToSquare
(
self
.
drawSquaresOption
.
isChecked
())
...
...
@@ -2254,6 +2323,7 @@ class MainWindow(QMainWindow):
self
.
itemsToShapesbox
.
clear
()
# ADD
self
.
shapesToItemsbox
.
clear
()
self
.
labelList
.
clear
()
self
.
indexList
.
clear
()
self
.
BoxList
.
clear
()
self
.
result_dic
=
[]
self
.
result_dic_locked
=
[]
...
...
@@ -2665,6 +2735,7 @@ class MainWindow(QMainWindow):
def
undoShapeEdit
(
self
):
self
.
canvas
.
restoreShape
()
self
.
labelList
.
clear
()
self
.
indexList
.
clear
()
self
.
BoxList
.
clear
()
self
.
loadShapes
(
self
.
canvas
.
shapes
)
self
.
actions
.
undo
.
setEnabled
(
self
.
canvas
.
isShapeRestorable
)
...
...
@@ -2674,6 +2745,7 @@ class MainWindow(QMainWindow):
for
shape
in
shapes
:
self
.
addLabel
(
shape
)
self
.
labelList
.
clearSelection
()
self
.
indexList
.
clearSelection
()
self
.
_noSelectionSlot
=
False
self
.
canvas
.
loadShapes
(
shapes
,
replace
=
replace
)
print
(
"loadShapes"
)
# 1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录