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
3458f85a
Unverified
Commit
3458f85a
authored
Oct 08, 2024
by
Xiaomeng Zhao
Committed by
GitHub
Oct 08, 2024
Browse files
Merge pull request #694 from myhloli/dev
perf(pdf_extract_kit): conditional memory cleanup based on GPU capacity
parents
69eb2c3b
fb9949c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
magic_pdf/model/pdf_extract_kit.py
magic_pdf/model/pdf_extract_kit.py
+10
-2
No files found.
magic_pdf/model/pdf_extract_kit.py
View file @
3458f85a
...
@@ -314,6 +314,7 @@ class CustomPEKModel:
...
@@ -314,6 +314,7 @@ class CustomPEKModel:
mfr_res
=
[]
mfr_res
=
[]
for
mf_img
in
dataloader
:
for
mf_img
in
dataloader
:
mf_img
=
mf_img
.
to
(
self
.
device
)
mf_img
=
mf_img
.
to
(
self
.
device
)
with
torch
.
no_grad
():
output
=
self
.
mfr_model
.
generate
({
'image'
:
mf_img
})
output
=
self
.
mfr_model
.
generate
({
'image'
:
mf_img
})
mfr_res
.
extend
(
output
[
'pred_str'
])
mfr_res
.
extend
(
output
[
'pred_str'
])
for
res
,
latex
in
zip
(
latex_filling_list
,
mfr_res
):
for
res
,
latex
in
zip
(
latex_filling_list
,
mfr_res
):
...
@@ -336,7 +337,14 @@ class CustomPEKModel:
...
@@ -336,7 +337,14 @@ class CustomPEKModel:
elif
int
(
res
[
'category_id'
])
in
[
5
]:
elif
int
(
res
[
'category_id'
])
in
[
5
]:
table_res_list
.
append
(
res
)
table_res_list
.
append
(
res
)
if
torch
.
cuda
.
is_available
():
properties
=
torch
.
cuda
.
get_device_properties
(
self
.
device
)
total_memory
=
properties
.
total_memory
/
(
1024
**
3
)
# 将字节转换为 GB
if
total_memory
<=
8
:
gc_start
=
time
.
time
()
clean_memory
()
clean_memory
()
gc_time
=
round
(
time
.
time
()
-
gc_start
,
2
)
logger
.
info
(
f
"gc time:
{
gc_time
}
"
)
# ocr识别
# ocr识别
if
self
.
apply_ocr
:
if
self
.
apply_ocr
:
...
...
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