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
MinerU
Commits
4c096443
"...git@developer.sourcefind.cn:OpenDAS/torch-scatter.git" did not exist on "1cd8aa6ef70fdaf6a9ffe5416bbfc44c0a02aa95"
Commit
4c096443
authored
Aug 01, 2024
by
liukaiwen
Browse files
add table recognition and convertion to LaTeX
parent
d04f3f22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
magic_pdf/model/pdf_extract_kit.py
magic_pdf/model/pdf_extract_kit.py
+3
-3
magic_pdf/model/pek_sub_modules/structeqtable/StructTableModel.py
...f/model/pek_sub_modules/structeqtable/StructTableModel.py
+5
-3
No files found.
magic_pdf/model/pdf_extract_kit.py
View file @
4c096443
...
@@ -35,8 +35,8 @@ from magic_pdf.model.pek_sub_modules.self_modify import ModifiedPaddleOCR
...
@@ -35,8 +35,8 @@ from magic_pdf.model.pek_sub_modules.self_modify import ModifiedPaddleOCR
from
magic_pdf.model.pek_sub_modules.structeqtable.StructTableModel
import
StructTableModel
from
magic_pdf.model.pek_sub_modules.structeqtable.StructTableModel
import
StructTableModel
def
table_model_init
(
model_path
):
def
table_model_init
(
model_path
,
_device_
=
'cpu'
):
table_model
=
StructTableModel
(
model_path
)
table_model
=
StructTableModel
(
model_path
,
device
=
_device_
)
return
table_model
return
table_model
...
@@ -140,7 +140,7 @@ class CustomPEKModel:
...
@@ -140,7 +140,7 @@ class CustomPEKModel:
# init structeqtable
# init structeqtable
if
self
.
apply_table
:
if
self
.
apply_table
:
self
.
table_model
=
table_model_init
(
str
(
os
.
path
.
join
(
models_dir
,
self
.
configs
[
"weights"
][
"table"
])))
self
.
table_model
=
table_model_init
(
str
(
os
.
path
.
join
(
models_dir
,
self
.
configs
[
"weights"
][
"table"
]))
,
_device_
=
self
.
device
)
logger
.
info
(
'DocAnalysis init done!'
)
logger
.
info
(
'DocAnalysis init done!'
)
def
__call__
(
self
,
image
):
def
__call__
(
self
,
image
):
...
...
magic_pdf/model/pek_sub_modules/structeqtable/StructTableModel.py
View file @
4c096443
from
struct_eqtable.model
import
StructTable
from
struct_eqtable.model
import
StructTable
from
pypandoc
import
convert_text
from
pypandoc
import
convert_text
class
StructTableModel
:
class
StructTableModel
:
def
__init__
(
self
,
model_path
,
max_new_tokens
=
2048
,
max_time
=
400
):
def
__init__
(
self
,
model_path
,
max_new_tokens
=
2048
,
max_time
=
400
,
device
=
'cpu'
):
# init
# init
self
.
model_path
=
model_path
self
.
model_path
=
model_path
self
.
max_new_tokens
=
max_new_tokens
# maximum output tokens length
self
.
max_new_tokens
=
max_new_tokens
# maximum output tokens length
self
.
max_time
=
max_time
# timeout for processing in seconds
self
.
max_time
=
max_time
# timeout for processing in seconds
self
.
model
=
StructTable
(
self
.
model_path
,
self
.
max_new_tokens
,
self
.
max_time
)
if
device
==
'cpu'
:
self
.
model
=
StructTable
(
self
.
model_path
,
self
.
max_new_tokens
,
self
.
max_time
)
else
:
self
.
model
=
StructTable
(
self
.
model_path
,
self
.
max_new_tokens
,
self
.
max_time
).
cuda
()
def
image2latex
(
self
,
image
)
->
str
:
def
image2latex
(
self
,
image
)
->
str
:
#
#
...
...
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