Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
ab17e963
Commit
ab17e963
authored
Feb 24, 2022
by
HinGwenWoong
Browse files
Saving key [key_cls] only --kie=True
parent
967f0676
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+17
-11
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
ab17e963
...
@@ -536,7 +536,7 @@ class MainWindow(QMainWindow):
...
@@ -536,7 +536,7 @@ class MainWindow(QMainWindow):
editMenu
=
(
createpoly
,
edit
,
copy
,
delete
,
singleRere
,
None
,
undo
,
undoLastPoint
,
editMenu
=
(
createpoly
,
edit
,
copy
,
delete
,
singleRere
,
None
,
undo
,
undoLastPoint
,
None
,
rotateLeft
,
rotateRight
,
None
,
color1
,
self
.
drawSquaresOption
,
lock
),
None
,
rotateLeft
,
rotateRight
,
None
,
color1
,
self
.
drawSquaresOption
,
lock
),
beginnerContext
=
(
beginnerContext
=
(
create
,
edit
,
copy
,
delete
,
singleRere
,
rotateLeft
,
rotateRight
,
lock
,
change_cls
),
create
,
edit
,
copy
,
delete
,
singleRere
,
rotateLeft
,
rotateRight
,
lock
,
change_cls
),
advancedContext
=
(
createMode
,
editMode
,
edit
,
copy
,
advancedContext
=
(
createMode
,
editMode
,
edit
,
copy
,
delete
,
shapeLineColor
,
shapeFillColor
),
delete
,
shapeLineColor
,
shapeFillColor
),
onLoadActive
=
(
create
,
createMode
,
editMode
),
onLoadActive
=
(
create
,
createMode
,
editMode
),
...
@@ -1105,7 +1105,9 @@ class MainWindow(QMainWindow):
...
@@ -1105,7 +1105,9 @@ class MainWindow(QMainWindow):
shapes
=
[
format_shape
(
shape
)
for
shape
in
self
.
canvas
.
shapes
if
shape
.
line_color
!=
DEFAULT_LOCK_COLOR
]
shapes
=
[
format_shape
(
shape
)
for
shape
in
self
.
canvas
.
shapes
if
shape
.
line_color
!=
DEFAULT_LOCK_COLOR
]
# Can add differrent annotation formats here
# Can add differrent annotation formats here
for
box
in
self
.
result_dic
:
for
box
in
self
.
result_dic
:
trans_dic
=
{
"label"
:
box
[
1
][
0
],
"points"
:
box
[
0
],
"difficult"
:
False
,
"key_cls"
:
"None"
}
trans_dic
=
{
"label"
:
box
[
1
][
0
],
"points"
:
box
[
0
],
"difficult"
:
False
}
if
self
.
kie_mode
:
trans_dic
.
update
({
"key_cls"
:
"None"
})
if
trans_dic
[
"label"
]
==
""
and
mode
==
'Auto'
:
if
trans_dic
[
"label"
]
==
""
and
mode
==
'Auto'
:
continue
continue
shapes
.
append
(
trans_dic
)
shapes
.
append
(
trans_dic
)
...
@@ -1113,8 +1115,10 @@ class MainWindow(QMainWindow):
...
@@ -1113,8 +1115,10 @@ class MainWindow(QMainWindow):
try
:
try
:
trans_dic
=
[]
trans_dic
=
[]
for
box
in
shapes
:
for
box
in
shapes
:
trans_dic
.
append
({
"transcription"
:
box
[
'label'
],
"points"
:
box
[
'points'
],
trans_dict
=
{
"transcription"
:
box
[
'label'
],
"points"
:
box
[
'points'
],
"difficult"
:
box
[
'difficult'
]}
"difficult"
:
box
[
'difficult'
],
"key_cls"
:
box
[
'key_cls'
]})
if
self
.
kie_mode
:
trans_dict
.
update
({
"key_cls"
:
box
[
'key_cls'
]})
trans_dic
.
append
(
trans_dict
)
self
.
PPlabel
[
annotationFilePath
]
=
trans_dic
self
.
PPlabel
[
annotationFilePath
]
=
trans_dic
if
mode
==
'Auto'
:
if
mode
==
'Auto'
:
self
.
Cachelabel
[
annotationFilePath
]
=
trans_dic
self
.
Cachelabel
[
annotationFilePath
]
=
trans_dic
...
@@ -1424,15 +1428,17 @@ class MainWindow(QMainWindow):
...
@@ -1424,15 +1428,17 @@ class MainWindow(QMainWindow):
# box['ratio'] of the shapes saved in lockedShapes contains the ratio of the
# box['ratio'] of the shapes saved in lockedShapes contains the ratio of the
# four corner coordinates of the shapes to the height and width of the image
# four corner coordinates of the shapes to the height and width of the image
for
box
in
self
.
canvas
.
lockedShapes
:
for
box
in
self
.
canvas
.
lockedShapes
:
key_cls
=
None
if
not
self
.
kie_mode
else
box
[
'key_cls'
]
if
self
.
canvas
.
isInTheSameImage
:
if
self
.
canvas
.
isInTheSameImage
:
shapes
.
append
((
box
[
'transcription'
],
[[
s
[
0
]
*
width
,
s
[
1
]
*
height
]
for
s
in
box
[
'ratio'
]],
shapes
.
append
((
box
[
'transcription'
],
[[
s
[
0
]
*
width
,
s
[
1
]
*
height
]
for
s
in
box
[
'ratio'
]],
DEFAULT_LOCK_COLOR
,
box
[
'
key_cls
'
]
,
box
[
'difficult'
]))
DEFAULT_LOCK_COLOR
,
key_cls
,
box
[
'difficult'
]))
else
:
else
:
shapes
.
append
((
'锁定框:待检测'
,
[[
s
[
0
]
*
width
,
s
[
1
]
*
height
]
for
s
in
box
[
'ratio'
]],
shapes
.
append
((
'锁定框:待检测'
,
[[
s
[
0
]
*
width
,
s
[
1
]
*
height
]
for
s
in
box
[
'ratio'
]],
DEFAULT_LOCK_COLOR
,
box
[
'
key_cls
'
]
,
box
[
'difficult'
]))
DEFAULT_LOCK_COLOR
,
key_cls
,
box
[
'difficult'
]))
if
imgidx
in
self
.
PPlabel
.
keys
():
if
imgidx
in
self
.
PPlabel
.
keys
():
for
box
in
self
.
PPlabel
[
imgidx
]:
for
box
in
self
.
PPlabel
[
imgidx
]:
shapes
.
append
((
box
[
'transcription'
],
box
[
'points'
],
None
,
box
[
'key_cls'
],
box
[
'difficult'
]))
key_cls
=
None
if
not
self
.
kie_mode
else
box
[
'key_cls'
]
shapes
.
append
((
box
[
'transcription'
],
box
[
'points'
],
None
,
key_cls
,
box
[
'difficult'
]))
self
.
loadLabels
(
shapes
)
self
.
loadLabels
(
shapes
)
self
.
canvas
.
verified
=
False
self
.
canvas
.
verified
=
False
...
@@ -1600,7 +1606,6 @@ class MainWindow(QMainWindow):
...
@@ -1600,7 +1606,6 @@ class MainWindow(QMainWindow):
else
:
else
:
self
.
keyDialog
.
labelList
.
addItems
(
self
.
existed_key_cls_set
)
self
.
keyDialog
.
labelList
.
addItems
(
self
.
existed_key_cls_set
)
def
importDirImages
(
self
,
dirpath
,
isDelete
=
False
):
def
importDirImages
(
self
,
dirpath
,
isDelete
=
False
):
if
not
self
.
mayContinue
()
or
not
dirpath
:
if
not
self
.
mayContinue
()
or
not
dirpath
:
return
return
...
@@ -2250,9 +2255,10 @@ class MainWindow(QMainWindow):
...
@@ -2250,9 +2255,10 @@ class MainWindow(QMainWindow):
shapes
=
[
format_shape
(
shape
)
for
shape
in
self
.
canvas
.
selectedShapes
]
shapes
=
[
format_shape
(
shape
)
for
shape
in
self
.
canvas
.
selectedShapes
]
trans_dic
=
[]
trans_dic
=
[]
for
box
in
shapes
:
for
box
in
shapes
:
trans_dic
.
append
({
"transcription"
:
box
[
'label'
],
"ratio"
:
box
[
'ratio'
],
trans_dict
=
{
"transcription"
:
box
[
'label'
],
"ratio"
:
box
[
'ratio'
],
"difficult"
:
box
[
'difficult'
]}
"difficult"
:
box
[
'difficult'
],
if
self
.
kie_mode
:
"key_cls"
:
"None"
if
"key_cls"
not
in
box
else
box
[
"key_cls"
]})
trans_dict
.
update
({
"key_cls"
:
box
[
"key_cls"
]})
trans_dic
.
append
(
trans_dict
)
self
.
canvas
.
lockedShapes
=
trans_dic
self
.
canvas
.
lockedShapes
=
trans_dic
self
.
actions
.
save
.
setEnabled
(
True
)
self
.
actions
.
save
.
setEnabled
(
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment