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
15be3c54
You need to sign in or sign up before continuing.
Commit
15be3c54
authored
May 05, 2022
by
Leif
Browse files
Auto stash before merge of "table" and "origin/new"
parent
e15cf0d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+23
-16
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
15be3c54
...
@@ -2131,7 +2131,7 @@ class MainWindow(QMainWindow):
...
@@ -2131,7 +2131,7 @@ class MainWindow(QMainWindow):
TableRec_excel_dir
=
self
.
lastOpenDir
+
'/tableRec_excel_output/'
TableRec_excel_dir
=
self
.
lastOpenDir
+
'/tableRec_excel_output/'
os
.
makedirs
(
TableRec_excel_dir
,
exist_ok
=
True
)
os
.
makedirs
(
TableRec_excel_dir
,
exist_ok
=
True
)
filename
=
os
.
path
.
basename
(
self
.
filePath
)
filename
,
_
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
self
.
filePath
)
)
excel_path
=
TableRec_excel_dir
+
'{}.xlsx'
.
format
(
filename
)
excel_path
=
TableRec_excel_dir
+
'{}.xlsx'
.
format
(
filename
)
if
res
is
None
:
if
res
is
None
:
...
@@ -2203,19 +2203,26 @@ class MainWindow(QMainWindow):
...
@@ -2203,19 +2203,26 @@ class MainWindow(QMainWindow):
return
return
# automatically open excel annotation file
# automatically open excel annotation file
try
:
if
platform
.
system
()
==
'Windows'
:
import
win32com.client
try
:
except
:
import
win32com.client
print
(
"CANNOT OPEN .xlsx. It could be one of the following reasons: "
\
except
:
"Only support Windows | No python win32com"
)
print
(
"CANNOT OPEN .xlsx. It could be one of the following reasons: "
\
"Only support Windows | No python win32com"
)
try
:
try
:
xl
=
win32com
.
client
.
Dispatch
(
"Excel.Application"
)
xl
=
win32com
.
client
.
Dispatch
(
"Excel.Application"
)
xl
.
Visible
=
True
xl
.
Visible
=
True
xl
.
Workbooks
.
Open
(
excel_path
)
xl
.
Workbooks
.
Open
(
excel_path
)
except
:
# excelEx = "You need to show the excel executable at this point"
print
(
"CANNOT OPEN .xlsx. It could be the following reasons: "
\
# subprocess.Popen([excelEx, excel_path])
".xlsx is not existed"
)
# os.startfile(excel_path)
except
:
print
(
"CANNOT OPEN .xlsx. It could be the following reasons: "
\
".xlsx is not existed"
)
else
:
os
.
system
(
'open '
+
os
.
path
.
normpath
(
excel_path
))
print
(
'time cost: '
,
time
.
time
()
-
start
)
print
(
'time cost: '
,
time
.
time
()
-
start
)
...
@@ -2337,7 +2344,7 @@ class MainWindow(QMainWindow):
...
@@ -2337,7 +2344,7 @@ class MainWindow(QMainWindow):
imgid
=
0
imgid
=
0
for
image_path
in
labeldict
.
keys
():
for
image_path
in
labeldict
.
keys
():
# load csv annotations
# load csv annotations
filename
=
os
.
path
.
basename
(
image_path
)
filename
,
_
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
image_path
)
)
csv_path
=
os
.
path
.
join
(
TableRec_excel_dir
,
filename
+
'.xlsx'
)
csv_path
=
os
.
path
.
join
(
TableRec_excel_dir
,
filename
+
'.xlsx'
)
if
not
os
.
path
.
exists
(
csv_path
):
if
not
os
.
path
.
exists
(
csv_path
):
msg
=
'ERROR, Can not find '
+
csv_path
msg
=
'ERROR, Can not find '
+
csv_path
...
@@ -2347,7 +2354,7 @@ class MainWindow(QMainWindow):
...
@@ -2347,7 +2354,7 @@ class MainWindow(QMainWindow):
# read xlsx file, convert to HTML
# read xlsx file, convert to HTML
xd
=
pd
.
ExcelFile
(
csv_path
)
xd
=
pd
.
ExcelFile
(
csv_path
)
df
=
xd
.
parse
()
df
=
xd
.
parse
()
structure
=
df
.
to_html
()
structure
=
df
.
to_html
(
index
=
False
)
# load box annotations
# load box annotations
cells
=
[]
cells
=
[]
...
@@ -2371,7 +2378,7 @@ class MainWindow(QMainWindow):
...
@@ -2371,7 +2378,7 @@ class MainWindow(QMainWindow):
imgid
+=
1
imgid
+=
1
# save json
# save json
with
open
(
"{}/annotation.json"
.
format
(
self
.
lastOpenDir
),
"w"
)
as
fid
:
with
open
(
"{}/annotation.json"
.
format
(
self
.
lastOpenDir
),
"w"
,
encoding
=
'utf-8'
)
as
fid
:
fid
.
write
(
json
.
dumps
(
json_results
))
fid
.
write
(
json
.
dumps
(
json_results
))
msg
=
'JSON sucessfully saved in {}/annotation.json'
.
format
(
self
.
lastOpenDir
)
msg
=
'JSON sucessfully saved in {}/annotation.json'
.
format
(
self
.
lastOpenDir
)
...
...
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