Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
cad701d4
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cad701d4
编写于
10月 24, 2022
作者:
文幕地方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix benckmark error when benckmark=false
上级
14efc410
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
120 addition
and
93 deletion
+120
-93
paddleocr.py
paddleocr.py
+1
-1
ppstructure/pdf2word/pdf2word.py
ppstructure/pdf2word/pdf2word.py
+111
-89
ppstructure/recovery/requirements.txt
ppstructure/recovery/requirements.txt
+2
-1
ppstructure/table/predict_table.py
ppstructure/table/predict_table.py
+6
-2
未找到文件。
paddleocr.py
浏览文件 @
cad701d4
...
@@ -47,7 +47,7 @@ __all__ = [
...
@@ -47,7 +47,7 @@ __all__ = [
]
]
SUPPORT_DET_MODEL
=
[
'DB'
]
SUPPORT_DET_MODEL
=
[
'DB'
]
VERSION
=
'2.6.
0.3
'
VERSION
=
'2.6.
1.0
'
SUPPORT_REC_MODEL
=
[
'CRNN'
,
'SVTR_LCNet'
]
SUPPORT_REC_MODEL
=
[
'CRNN'
,
'SVTR_LCNet'
]
BASE_DIR
=
os
.
path
.
expanduser
(
"~/.paddleocr/"
)
BASE_DIR
=
os
.
path
.
expanduser
(
"~/.paddleocr/"
)
...
...
ppstructure/pdf2word/pdf2word.py
浏览文件 @
cad701d4
# copyright (c) 2022 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
sys
import
sys
import
tarfile
import
tarfile
import
os
import
os
...
@@ -20,7 +34,6 @@ root = os.path.abspath(os.path.join(file, '../../'))
...
@@ -20,7 +34,6 @@ root = os.path.abspath(os.path.join(file, '../../'))
sys
.
path
.
append
(
file
)
sys
.
path
.
append
(
file
)
sys
.
path
.
insert
(
0
,
root
)
sys
.
path
.
insert
(
0
,
root
)
from
ppstructure.predict_system
import
StructureSystem
,
save_structure_res
from
ppstructure.predict_system
import
StructureSystem
,
save_structure_res
from
ppstructure.utility
import
parse_args
,
draw_structure_result
from
ppstructure.utility
import
parse_args
,
draw_structure_result
from
ppocr.utils.network
import
download_with_progressbar
from
ppocr.utils.network
import
download_with_progressbar
...
@@ -32,13 +45,17 @@ __VERSION__ = "0.2.2"
...
@@ -32,13 +45,17 @@ __VERSION__ = "0.2.2"
URLs_EN
=
{
URLs_EN
=
{
# 下载超英文轻量级PP-OCRv3模型的检测模型并解压
# 下载超英文轻量级PP-OCRv3模型的检测模型并解压
"en_PP-OCRv3_det_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar"
,
"en_PP-OCRv3_det_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar"
,
# 下载英文轻量级PP-OCRv3模型的识别模型并解压
# 下载英文轻量级PP-OCRv3模型的识别模型并解压
"en_PP-OCRv3_rec_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_rec_infer.tar"
,
"en_PP-OCRv3_rec_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_rec_infer.tar"
,
# 下载超轻量级英文表格英文模型并解压
# 下载超轻量级英文表格英文模型并解压
"en_ppstructure_mobile_v2.0_SLANet_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar"
,
"en_ppstructure_mobile_v2.0_SLANet_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar"
,
# 英文版面分析模型
# 英文版面分析模型
"picodet_lcnet_x1_0_fgd_layout_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_infer.tar"
,
"picodet_lcnet_x1_0_fgd_layout_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_infer.tar"
,
}
}
DICT_EN
=
{
DICT_EN
=
{
"rec_char_dict_path"
:
"en_dict.txt"
,
"rec_char_dict_path"
:
"en_dict.txt"
,
...
@@ -47,13 +64,17 @@ DICT_EN = {
...
@@ -47,13 +64,17 @@ DICT_EN = {
URLs_CN
=
{
URLs_CN
=
{
# 下载超中文轻量级PP-OCRv3模型的检测模型并解压
# 下载超中文轻量级PP-OCRv3模型的检测模型并解压
"cn_PP-OCRv3_det_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar"
,
"cn_PP-OCRv3_det_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar"
,
# 下载中文轻量级PP-OCRv3模型的识别模型并解压
# 下载中文轻量级PP-OCRv3模型的识别模型并解压
"cn_PP-OCRv3_rec_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar"
,
"cn_PP-OCRv3_rec_infer"
:
"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar"
,
# 下载超轻量级英文表格英文模型并解压
# 下载超轻量级英文表格英文模型并解压
"cn_ppstructure_mobile_v2.0_SLANet_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar"
,
"cn_ppstructure_mobile_v2.0_SLANet_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar"
,
# 中文版面分析模型
# 中文版面分析模型
"picodet_lcnet_x1_0_fgd_layout_cdla_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar"
,
"picodet_lcnet_x1_0_fgd_layout_cdla_infer"
:
"https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar"
,
}
}
DICT_CN
=
{
DICT_CN
=
{
"rec_char_dict_path"
:
"ppocr_keys_v1.txt"
,
"rec_char_dict_path"
:
"ppocr_keys_v1.txt"
,
...
@@ -61,7 +82,6 @@ DICT_CN = {
...
@@ -61,7 +82,6 @@ DICT_CN = {
}
}
def
QImageToCvMat
(
incomingImage
)
->
np
.
array
:
def
QImageToCvMat
(
incomingImage
)
->
np
.
array
:
'''
'''
Converts a QImage into an opencv MAT format
Converts a QImage into an opencv MAT format
...
@@ -120,7 +140,7 @@ class Worker(QThread):
...
@@ -120,7 +140,7 @@ class Worker(QThread):
self
.
outputDir
=
None
self
.
outputDir
=
None
self
.
totalPageCnt
=
0
self
.
totalPageCnt
=
0
self
.
pageCnt
=
0
self
.
pageCnt
=
0
self
.
setStackSize
(
1024
*
1024
)
self
.
setStackSize
(
1024
*
1024
)
def
setImagePath
(
self
,
imagePaths
):
def
setImagePath
(
self
,
imagePaths
):
self
.
imagePaths
=
imagePaths
self
.
imagePaths
=
imagePaths
...
@@ -167,8 +187,8 @@ class Worker(QThread):
...
@@ -167,8 +187,8 @@ class Worker(QThread):
try
:
try
:
convert_info_docx
(
imgs
,
all_res
,
self
.
outputDir
,
img_name
)
convert_info_docx
(
imgs
,
all_res
,
self
.
outputDir
,
img_name
)
except
Exception
as
ex
:
except
Exception
as
ex
:
print
(
"error in layout recovery image:{}, err msg: {}"
.
print
(
"error in layout recovery image:{}, err msg: {}"
.
format
(
format
(
img_name
,
ex
))
img_name
,
ex
))
print
(
"Predict time : {:.3f}s"
.
format
(
time_dict
[
'all'
]))
print
(
"Predict time : {:.3f}s"
.
format
(
time_dict
[
'all'
]))
print
(
'result save to {}'
.
format
(
self
.
outputDir
))
print
(
'result save to {}'
.
format
(
self
.
outputDir
))
...
@@ -185,10 +205,11 @@ class Worker(QThread):
...
@@ -185,10 +205,11 @@ class Worker(QThread):
and
os
.
path
.
basename
(
image_file
)[
-
3
:]
==
'pdf'
:
and
os
.
path
.
basename
(
image_file
)[
-
3
:]
==
'pdf'
:
self
.
totalPageCnt
+=
1
self
.
totalPageCnt
+=
1
self
.
progressBarRange
.
emit
(
self
.
totalPageCnt
)
self
.
progressBarRange
.
emit
(
self
.
totalPageCnt
)
print
(
'===============using use_pdf2docx_api==============='
)
print
(
'===============using use_pdf2docx_api==============='
)
img_name
=
os
.
path
.
basename
(
image_file
).
split
(
'.'
)[
0
]
img_name
=
os
.
path
.
basename
(
image_file
).
split
(
'.'
)[
0
]
docx_file
=
os
.
path
.
join
(
docx_file
=
os
.
path
.
join
(
self
.
outputDir
,
self
.
outputDir
,
'{}.docx'
.
format
(
img_name
))
'{}.docx'
.
format
(
img_name
))
cv
=
Converter
(
image_file
)
cv
=
Converter
(
image_file
)
cv
.
convert
(
docx_file
)
cv
.
convert
(
docx_file
)
cv
.
close
()
cv
.
close
()
...
@@ -201,7 +222,8 @@ class Worker(QThread):
...
@@ -201,7 +222,8 @@ class Worker(QThread):
if
len
(
imgs
)
==
0
:
if
len
(
imgs
)
==
0
:
continue
continue
img_name
=
os
.
path
.
basename
(
image_file
).
split
(
'.'
)[
0
]
img_name
=
os
.
path
.
basename
(
image_file
).
split
(
'.'
)[
0
]
os
.
makedirs
(
os
.
path
.
join
(
self
.
outputDir
,
img_name
),
exist_ok
=
True
)
os
.
makedirs
(
os
.
path
.
join
(
self
.
outputDir
,
img_name
),
exist_ok
=
True
)
self
.
ppocrPrecitor
(
imgs
,
img_name
)
self
.
ppocrPrecitor
(
imgs
,
img_name
)
# file processed
# file processed
self
.
endsignal
.
emit
()
self
.
endsignal
.
emit
()
...
@@ -222,8 +244,7 @@ class APP_Image2Doc(QWidget):
...
@@ -222,8 +244,7 @@ class APP_Image2Doc(QWidget):
self
.
screenShot
=
None
self
.
screenShot
=
None
self
.
save_pdf
=
False
self
.
save_pdf
=
False
self
.
output_dir
=
None
self
.
output_dir
=
None
self
.
vis_font_path
=
os
.
path
.
join
(
root
,
self
.
vis_font_path
=
os
.
path
.
join
(
root
,
"doc"
,
"fonts"
,
"simfang.ttf"
)
"doc"
,
"fonts"
,
"simfang.ttf"
)
self
.
use_pdf2docx_api
=
False
self
.
use_pdf2docx_api
=
False
# ProgressBar
# ProgressBar
...
@@ -245,8 +266,10 @@ class APP_Image2Doc(QWidget):
...
@@ -245,8 +266,10 @@ class APP_Image2Doc(QWidget):
}
}
# 设置工作进程
# 设置工作进程
self
.
_thread
=
Worker
(
predictors
,
self
.
save_pdf
,
self
.
vis_font_path
,
self
.
use_pdf2docx_api
)
self
.
_thread
=
Worker
(
predictors
,
self
.
save_pdf
,
self
.
vis_font_path
,
self
.
_thread
.
progressBarValue
.
connect
(
self
.
handleProgressBarUpdateSingal
)
self
.
use_pdf2docx_api
)
self
.
_thread
.
progressBarValue
.
connect
(
self
.
handleProgressBarUpdateSingal
)
self
.
_thread
.
endsignal
.
connect
(
self
.
handleEndsignalSignal
)
self
.
_thread
.
endsignal
.
connect
(
self
.
handleEndsignalSignal
)
# self._thread.finished.connect(QObject.deleteLater)
# self._thread.finished.connect(QObject.deleteLater)
self
.
_thread
.
progressBarRange
.
connect
(
self
.
handleProgressBarRangeSingal
)
self
.
_thread
.
progressBarRange
.
connect
(
self
.
handleProgressBarRangeSingal
)
...
@@ -294,8 +317,7 @@ class APP_Image2Doc(QWidget):
...
@@ -294,8 +317,7 @@ class APP_Image2Doc(QWidget):
# ProgressBar
# ProgressBar
layout
.
addWidget
(
self
.
pb
,
2
,
0
,
1
,
5
)
layout
.
addWidget
(
self
.
pb
,
2
,
0
,
1
,
5
)
# time estimate label
# time estimate label
self
.
timeEstLabel
=
QLabel
(
self
.
timeEstLabel
=
QLabel
((
"Time Left: --"
))
(
"Time Left: --"
))
layout
.
addWidget
(
self
.
timeEstLabel
,
3
,
0
,
1
,
5
)
layout
.
addWidget
(
self
.
timeEstLabel
,
3
,
0
,
1
,
5
)
self
.
setLayout
(
layout
)
self
.
setLayout
(
layout
)
...
@@ -303,11 +325,8 @@ class APP_Image2Doc(QWidget):
...
@@ -303,11 +325,8 @@ class APP_Image2Doc(QWidget):
def
downloadModels
(
self
,
URLs
):
def
downloadModels
(
self
,
URLs
):
# using custom model
# using custom model
tar_file_name_list
=
[
tar_file_name_list
=
[
'inference.pdiparams'
,
'inference.pdiparams'
,
'inference.pdiparams.info'
,
'inference.pdiparams.info'
,
'inference.pdmodel'
,
'model.pdiparams'
,
'model.pdiparams.info'
,
'inference.pdmodel'
,
'model.pdiparams'
,
'model.pdiparams.info'
,
'model.pdmodel'
'model.pdmodel'
]
]
model_path
=
os
.
path
.
join
(
root
,
'inference'
)
model_path
=
os
.
path
.
join
(
root
,
'inference'
)
...
@@ -325,7 +344,8 @@ class APP_Image2Doc(QWidget):
...
@@ -325,7 +344,8 @@ class APP_Image2Doc(QWidget):
try
:
try
:
download_with_progressbar
(
url
,
tarpath
)
download_with_progressbar
(
url
,
tarpath
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
"Error occurred when downloading file, error message:"
)
print
(
"Error occurred when downloading file, error message:"
)
print
(
e
)
print
(
e
)
# unzip model tar
# unzip model tar
...
@@ -341,8 +361,7 @@ class APP_Image2Doc(QWidget):
...
@@ -341,8 +361,7 @@ class APP_Image2Doc(QWidget):
if
filename
is
None
:
if
filename
is
None
:
continue
continue
file
=
tarObj
.
extractfile
(
member
)
file
=
tarObj
.
extractfile
(
member
)
with
open
(
with
open
(
os
.
path
.
join
(
storage_dir
,
filename
),
os
.
path
.
join
(
storage_dir
,
filename
),
'wb'
)
as
f
:
'wb'
)
as
f
:
f
.
write
(
file
.
read
())
f
.
write
(
file
.
read
())
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -356,37 +375,40 @@ class APP_Image2Doc(QWidget):
...
@@ -356,37 +375,40 @@ class APP_Image2Doc(QWidget):
args
.
ocr
=
True
args
.
ocr
=
True
args
.
recovery
=
True
args
.
recovery
=
True
args
.
save_pdf
=
self
.
save_pdf
args
.
save_pdf
=
self
.
save_pdf
args
.
table_char_dict_path
=
os
.
path
.
join
(
root
,
args
.
table_char_dict_path
=
os
.
path
.
join
(
root
,
"ppocr"
,
"utils"
,
"dict"
,
"ppocr"
,
"utils"
,
"dict"
,
"table_structure_dict.txt"
)
"table_structure_dict.txt"
)
if
lang
==
'EN'
:
if
lang
==
'EN'
:
args
.
det_model_dir
=
os
.
path
.
join
(
root
,
# 此处从这里找到模型存放位置
args
.
det_model_dir
=
os
.
path
.
join
(
"inference"
,
"en_PP-OCRv3_det_infer"
)
root
,
# 此处从这里找到模型存放位置
args
.
rec_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"inference"
,
"en_PP-OCRv3_rec_infer"
)
"en_PP-OCRv3_det_infer"
)
args
.
table_model_dir
=
os
.
path
.
join
(
root
,
args
.
rec_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"inference"
,
"en_ppstructure_mobile_v2.0_SLANet_infer"
)
"en_PP-OCRv3_rec_infer"
)
args
.
table_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"en_ppstructure_mobile_v2.0_SLANet_infer"
)
args
.
output
=
os
.
path
.
join
(
root
,
"output"
)
# 结果保存路径
args
.
output
=
os
.
path
.
join
(
root
,
"output"
)
# 结果保存路径
args
.
layout_model_dir
=
os
.
path
.
join
(
root
,
args
.
layout_model_dir
=
os
.
path
.
join
(
"inference"
,
"picodet_lcnet_x1_0_fgd_layout_infer"
)
root
,
"inference"
,
"picodet_lcnet_x1_0_fgd_layout_infer"
)
lang_dict
=
DICT_EN
lang_dict
=
DICT_EN
elif
lang
==
'CN'
:
elif
lang
==
'CN'
:
args
.
det_model_dir
=
os
.
path
.
join
(
root
,
# 此处从这里找到模型存放位置
args
.
det_model_dir
=
os
.
path
.
join
(
"inference"
,
"cn_PP-OCRv3_det_infer"
)
root
,
# 此处从这里找到模型存放位置
args
.
rec_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"inference"
,
"cn_PP-OCRv3_rec_infer"
)
"cn_PP-OCRv3_det_infer"
)
args
.
table_model_dir
=
os
.
path
.
join
(
root
,
args
.
rec_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"inference"
,
"cn_ppstructure_mobile_v2.0_SLANet_infer"
)
"cn_PP-OCRv3_rec_infer"
)
args
.
table_model_dir
=
os
.
path
.
join
(
root
,
"inference"
,
"cn_ppstructure_mobile_v2.0_SLANet_infer"
)
args
.
output
=
os
.
path
.
join
(
root
,
"output"
)
# 结果保存路径
args
.
output
=
os
.
path
.
join
(
root
,
"output"
)
# 结果保存路径
args
.
layout_model_dir
=
os
.
path
.
join
(
root
,
args
.
layout_model_dir
=
os
.
path
.
join
(
"inference"
,
"picodet_lcnet_x1_0_fgd_layout_cdla_infer"
)
root
,
"inference"
,
"picodet_lcnet_x1_0_fgd_layout_cdla_infer"
)
lang_dict
=
DICT_CN
lang_dict
=
DICT_CN
else
:
else
:
raise
ValueError
(
"Unsupported language"
)
raise
ValueError
(
"Unsupported language"
)
args
.
rec_char_dict_path
=
os
.
path
.
join
(
root
,
args
.
rec_char_dict_path
=
os
.
path
.
join
(
root
,
"ppocr"
,
"utils"
,
"ppocr"
,
"utils"
,
lang_dict
[
'rec_char_dict_path'
])
lang_dict
[
'rec_char_dict_path'
])
args
.
layout_dict_path
=
os
.
path
.
join
(
root
,
args
.
layout_dict_path
=
os
.
path
.
join
(
root
,
"ppocr"
,
"utils"
,
"dict"
,
"ppocr"
,
"utils"
,
"dict"
,
"layout_dict"
,
"layout_dict"
,
lang_dict
[
'layout_dict_path'
])
lang_dict
[
'layout_dict_path'
])
# init predictor
# init predictor
return
StructureSystem
(
args
)
return
StructureSystem
(
args
)
...
@@ -395,8 +417,8 @@ class APP_Image2Doc(QWidget):
...
@@ -395,8 +417,8 @@ class APP_Image2Doc(QWidget):
'''
'''
可以多选图像文件
可以多选图像文件
'''
'''
selectedFiles
=
QFileDialog
.
getOpenFileNames
(
self
,
selectedFiles
=
QFileDialog
.
getOpenFileNames
(
"多文件选择"
,
"/"
,
"图片文件 (*.png *.jpeg *.jpg *.bmp *.pdf)"
)[
0
]
self
,
"多文件选择"
,
"/"
,
"图片文件 (*.png *.jpeg *.jpg *.bmp *.pdf)"
)[
0
]
if
len
(
selectedFiles
)
>
0
:
if
len
(
selectedFiles
)
>
0
:
self
.
imagePaths
=
selectedFiles
self
.
imagePaths
=
selectedFiles
self
.
screenShot
=
None
# discard screenshot temp image
self
.
screenShot
=
None
# discard screenshot temp image
...
@@ -416,17 +438,18 @@ class APP_Image2Doc(QWidget):
...
@@ -416,17 +438,18 @@ class APP_Image2Doc(QWidget):
def
handleStartSignal
(
self
,
lang
=
'EN'
,
pdfParser
=
False
):
def
handleStartSignal
(
self
,
lang
=
'EN'
,
pdfParser
=
False
):
if
self
.
screenShot
:
# for screenShot
if
self
.
screenShot
:
# for screenShot
img_name
=
'screenshot_'
+
time
.
strftime
(
"%Y%m%d%H%M%S"
,
time
.
localtime
())
img_name
=
'screenshot_'
+
time
.
strftime
(
"%Y%m%d%H%M%S"
,
time
.
localtime
())
image
=
QImageToCvMat
(
self
.
screenShot
)
image
=
QImageToCvMat
(
self
.
screenShot
)
self
.
predictAndSave
(
image
,
img_name
,
lang
)
self
.
predictAndSave
(
image
,
img_name
,
lang
)
# update Progress Bar
# update Progress Bar
self
.
pb
.
setValue
(
1
)
self
.
pb
.
setValue
(
1
)
QMessageBox
.
information
(
self
,
QMessageBox
.
information
(
self
,
u
'Information'
,
"文档提取完成"
)
u
'Information'
,
"文档提取完成"
)
elif
len
(
self
.
imagePaths
)
>
0
:
# for image file selection
elif
len
(
self
.
imagePaths
)
>
0
:
# for image file selection
# Must set image path list and language before start
# Must set image path list and language before start
self
.
output_dir
=
os
.
path
.
join
(
self
.
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
self
.
imagePaths
[
0
]),
"output"
)
# output_dir shold be same as imagepath
os
.
path
.
dirname
(
self
.
imagePaths
[
0
]),
"output"
)
# output_dir shold be same as imagepath
self
.
_thread
.
setOutputDir
(
self
.
output_dir
)
self
.
_thread
.
setOutputDir
(
self
.
output_dir
)
self
.
_thread
.
setImagePath
(
self
.
imagePaths
)
self
.
_thread
.
setImagePath
(
self
.
imagePaths
)
self
.
_thread
.
setLang
(
lang
)
self
.
_thread
.
setLang
(
lang
)
...
@@ -439,11 +462,9 @@ class APP_Image2Doc(QWidget):
...
@@ -439,11 +462,9 @@ class APP_Image2Doc(QWidget):
# 启动工作进程
# 启动工作进程
self
.
_thread
.
start
()
self
.
_thread
.
start
()
self
.
time_start
=
time
.
time
()
# log start time
self
.
time_start
=
time
.
time
()
# log start time
QMessageBox
.
information
(
self
,
QMessageBox
.
information
(
self
,
u
'Information'
,
"开始转换"
)
u
'Information'
,
"开始转换"
)
else
:
else
:
QMessageBox
.
warning
(
self
,
QMessageBox
.
warning
(
self
,
u
'Information'
,
"请选择要识别的文件或截图"
)
u
'Information'
,
"请选择要识别的文件或截图"
)
def
handleShowResultSignal
(
self
):
def
handleShowResultSignal
(
self
):
if
self
.
output_dir
is
None
:
if
self
.
output_dir
is
None
:
...
@@ -454,15 +475,16 @@ class APP_Image2Doc(QWidget):
...
@@ -454,15 +475,16 @@ class APP_Image2Doc(QWidget):
else
:
else
:
os
.
system
(
'open '
+
os
.
path
.
normpath
(
self
.
output_dir
))
os
.
system
(
'open '
+
os
.
path
.
normpath
(
self
.
output_dir
))
else
:
else
:
QMessageBox
.
information
(
self
,
QMessageBox
.
information
(
self
,
u
'Information'
,
"输出文件不存在"
)
u
'Information'
,
"输出文件不存在"
)
def
handleProgressBarUpdateSingal
(
self
,
i
):
def
handleProgressBarUpdateSingal
(
self
,
i
):
self
.
pb
.
setValue
(
i
)
self
.
pb
.
setValue
(
i
)
# calculate time left of recognition
# calculate time left of recognition
lenbar
=
self
.
pb
.
maximum
()
lenbar
=
self
.
pb
.
maximum
()
avg_time
=
(
time
.
time
()
-
self
.
time_start
)
/
i
# Use average time to prevent time fluctuations
avg_time
=
(
time
.
time
()
-
self
.
time_start
time_left
=
str
(
datetime
.
timedelta
(
seconds
=
avg_time
*
(
lenbar
-
i
))).
split
(
"."
)[
0
]
# Remove microseconds
)
/
i
# Use average time to prevent time fluctuations
time_left
=
str
(
datetime
.
timedelta
(
seconds
=
avg_time
*
(
lenbar
-
i
))).
split
(
"."
)[
0
]
# Remove microseconds
self
.
timeEstLabel
.
setText
(
f
"Time Left:
{
time_left
}
"
)
# show time left
self
.
timeEstLabel
.
setText
(
f
"Time Left:
{
time_left
}
"
)
# show time left
def
handleProgressBarRangeSingal
(
self
,
max
):
def
handleProgressBarRangeSingal
(
self
,
max
):
...
...
ppstructure/recovery/requirements.txt
浏览文件 @
cad701d4
...
@@ -3,3 +3,4 @@ PyMuPDF==1.19.0
...
@@ -3,3 +3,4 @@ PyMuPDF==1.19.0
beautifulsoup4
beautifulsoup4
fonttools>=4.24.0
fonttools>=4.24.0
fire>=0.3.0
fire>=0.3.0
pdf2docx
\ No newline at end of file
ppstructure/table/predict_table.py
浏览文件 @
cad701d4
...
@@ -60,11 +60,15 @@ class TableSystem(object):
...
@@ -60,11 +60,15 @@ class TableSystem(object):
self
.
args
=
args
self
.
args
=
args
if
not
args
.
show_log
:
if
not
args
.
show_log
:
logger
.
setLevel
(
logging
.
INFO
)
logger
.
setLevel
(
logging
.
INFO
)
benchmark_tmp
=
False
if
args
.
benchmark
:
benchmark_tmp
=
args
.
benchmark
args
.
benchmark
=
False
args
.
benchmark
=
False
self
.
text_detector
=
predict_det
.
TextDetector
(
copy
.
deepcopy
(
self
.
text_detector
=
predict_det
.
TextDetector
(
copy
.
deepcopy
(
args
))
if
text_detector
is
None
else
text_detector
args
))
if
text_detector
is
None
else
text_detector
self
.
text_recognizer
=
predict_rec
.
TextRecognizer
(
copy
.
deepcopy
(
self
.
text_recognizer
=
predict_rec
.
TextRecognizer
(
copy
.
deepcopy
(
args
))
if
text_recognizer
is
None
else
text_recognizer
args
))
if
text_recognizer
is
None
else
text_recognizer
if
benchmark_tmp
:
args
.
benchmark
=
True
args
.
benchmark
=
True
self
.
table_structurer
=
predict_strture
.
TableStructurer
(
args
)
self
.
table_structurer
=
predict_strture
.
TableStructurer
(
args
)
if
args
.
table_algorithm
in
[
'TableMaster'
]:
if
args
.
table_algorithm
in
[
'TableMaster'
]:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录