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
ec770f64
Commit
ec770f64
authored
Feb 20, 2022
by
HinGwenWoong
Browse files
After auto labeling, add None to key list at the same time
parent
3cf0237f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
26 deletions
+36
-26
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+36
-26
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
ec770f64
...
@@ -1565,6 +1565,39 @@ class MainWindow(QMainWindow):
...
@@ -1565,6 +1565,39 @@ class MainWindow(QMainWindow):
self
.
actions
.
open_dataset_dir
.
setEnabled
(
False
)
self
.
actions
.
open_dataset_dir
.
setEnabled
(
False
)
defaultOpenDirPath
=
os
.
path
.
dirname
(
self
.
filePath
)
if
self
.
filePath
else
'.'
defaultOpenDirPath
=
os
.
path
.
dirname
(
self
.
filePath
)
if
self
.
filePath
else
'.'
def
init_key_list
(
self
,
label_dict
):
if
not
self
.
kie_mode
:
return
# load key_cls
for
image
,
info
in
label_dict
.
items
():
for
box
in
info
:
if
"key_cls"
not
in
box
:
continue
self
.
existed_key_cls_set
.
add
(
box
[
"key_cls"
])
if
len
(
self
.
existed_key_cls_set
)
>
0
:
for
key_text
in
self
.
existed_key_cls_set
:
if
not
self
.
keyList
.
findItemsByLabel
(
key_text
):
item
=
self
.
keyList
.
createItemFromLabel
(
key_text
)
self
.
keyList
.
addItem
(
item
)
rgb
=
self
.
_get_rgb_by_label
(
key_text
,
self
.
kie_mode
)
self
.
keyList
.
setItemLabel
(
item
,
key_text
,
rgb
)
if
self
.
keyDialog
is
None
:
# key list dialog
self
.
keyDialog
=
KeyDialog
(
text
=
self
.
key_dialog_tip
,
parent
=
self
,
labels
=
self
.
existed_key_cls_set
,
sort_labels
=
True
,
show_text_field
=
True
,
completion
=
"startswith"
,
fit_to_content
=
{
'column'
:
True
,
'row'
:
False
},
flags
=
None
)
else
:
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
...
@@ -1580,32 +1613,7 @@ class MainWindow(QMainWindow):
...
@@ -1580,32 +1613,7 @@ class MainWindow(QMainWindow):
if
self
.
Cachelabel
:
if
self
.
Cachelabel
:
self
.
PPlabel
=
dict
(
self
.
Cachelabel
,
**
self
.
PPlabel
)
self
.
PPlabel
=
dict
(
self
.
Cachelabel
,
**
self
.
PPlabel
)
if
self
.
kie_mode
:
self
.
init_key_list
(
self
.
PPlabel
)
# load key_cls
for
image
,
info
in
self
.
PPlabel
.
items
():
for
box
in
info
:
if
"key_cls"
not
in
box
:
continue
self
.
existed_key_cls_set
.
add
(
box
[
"key_cls"
])
if
len
(
self
.
existed_key_cls_set
)
>
0
:
for
key_text
in
self
.
existed_key_cls_set
:
if
not
self
.
keyList
.
findItemsByLabel
(
key_text
):
item
=
self
.
keyList
.
createItemFromLabel
(
key_text
)
self
.
keyList
.
addItem
(
item
)
rgb
=
self
.
_get_rgb_by_label
(
key_text
,
self
.
kie_mode
)
self
.
keyList
.
setItemLabel
(
item
,
key_text
,
rgb
)
# key list dialog
self
.
keyDialog
=
KeyDialog
(
text
=
self
.
key_dialog_tip
,
parent
=
self
,
labels
=
self
.
existed_key_cls_set
,
sort_labels
=
True
,
show_text_field
=
True
,
completion
=
"startswith"
,
fit_to_content
=
{
'column'
:
True
,
'row'
:
False
},
flags
=
None
)
self
.
lastOpenDir
=
dirpath
self
.
lastOpenDir
=
dirpath
self
.
dirname
=
dirpath
self
.
dirname
=
dirpath
...
@@ -1943,6 +1951,8 @@ class MainWindow(QMainWindow):
...
@@ -1943,6 +1951,8 @@ class MainWindow(QMainWindow):
self
.
setDirty
()
self
.
setDirty
()
self
.
saveCacheLabel
()
self
.
saveCacheLabel
()
self
.
init_key_list
(
self
.
Cachelabel
)
def
reRecognition
(
self
):
def
reRecognition
(
self
):
img
=
cv2
.
imread
(
self
.
filePath
)
img
=
cv2
.
imread
(
self
.
filePath
)
# org_box = [dic['points'] for dic in self.PPlabel[self.getImglabelidx(self.filePath)]]
# org_box = [dic['points'] for dic in self.PPlabel[self.getImglabelidx(self.filePath)]]
...
...
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