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
4243b0ea
Commit
4243b0ea
authored
Jun 23, 2025
by
myhloli
Browse files
refactor: increase YOLO layout base batch size and improve progress tracking in predictions
parent
037a3ae6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
17 deletions
+21
-17
mineru/backend/pipeline/batch_analyze.py
mineru/backend/pipeline/batch_analyze.py
+1
-1
mineru/model/layout/doclayout_yolo.py
mineru/model/layout/doclayout_yolo.py
+13
-11
mineru/model/mfd/yolo_v8.py
mineru/model/mfd/yolo_v8.py
+6
-4
mineru/utils/pdf_reader.py
mineru/utils/pdf_reader.py
+1
-1
No files found.
mineru/backend/pipeline/batch_analyze.py
View file @
4243b0ea
...
...
@@ -9,7 +9,7 @@ from ...utils.config_reader import get_formula_enable, get_table_enable
from
...utils.model_utils
import
crop_img
,
get_res_list_from_layout_res
from
...utils.ocr_utils
import
get_adjusted_mfdetrec_res
,
get_ocr_result_list
,
OcrConfidence
YOLO_LAYOUT_BASE_BATCH_SIZE
=
1
YOLO_LAYOUT_BASE_BATCH_SIZE
=
8
MFD_BASE_BATCH_SIZE
=
1
MFR_BASE_BATCH_SIZE
=
16
...
...
mineru/model/layout/doclayout_yolo.py
View file @
4243b0ea
...
...
@@ -57,15 +57,17 @@ class DocLayoutYOLOModel:
batch_size
:
int
=
4
)
->
List
[
List
[
Dict
]]:
results
=
[]
for
idx
in
tqdm
(
range
(
0
,
len
(
images
),
batch_size
),
desc
=
"Layout Predict"
):
batch
=
images
[
idx
:
idx
+
batch_size
]
predictions
=
self
.
model
.
predict
(
batch
,
imgsz
=
self
.
imgsz
,
conf
=
self
.
conf
,
iou
=
self
.
iou
,
verbose
=
False
,
)
for
pred
in
predictions
:
results
.
append
(
self
.
_parse_prediction
(
pred
))
with
tqdm
(
total
=
len
(
images
),
desc
=
"Layout Predict"
)
as
pbar
:
for
idx
in
range
(
0
,
len
(
images
),
batch_size
):
batch
=
images
[
idx
:
idx
+
batch_size
]
predictions
=
self
.
model
.
predict
(
batch
,
imgsz
=
self
.
imgsz
,
conf
=
self
.
conf
,
iou
=
self
.
iou
,
verbose
=
False
,
)
for
pred
in
predictions
:
results
.
append
(
self
.
_parse_prediction
(
pred
))
pbar
.
update
(
len
(
batch
))
return
results
\ No newline at end of file
mineru/model/mfd/yolo_v8.py
View file @
4243b0ea
...
...
@@ -44,8 +44,10 @@ class YOLOv8MFDModel:
batch_size
:
int
=
4
)
->
List
:
results
=
[]
for
idx
in
tqdm
(
range
(
0
,
len
(
images
),
batch_size
),
desc
=
"MFD Predict"
):
batch
=
images
[
idx
:
idx
+
batch_size
]
batch_preds
=
self
.
_run_predict
(
batch
,
is_batch
=
True
)
results
.
extend
(
batch_preds
)
with
tqdm
(
total
=
len
(
images
),
desc
=
"MFD Predict"
)
as
pbar
:
for
idx
in
range
(
0
,
len
(
images
),
batch_size
):
batch
=
images
[
idx
:
idx
+
batch_size
]
batch_preds
=
self
.
_run_predict
(
batch
,
is_batch
=
True
)
results
.
extend
(
batch_preds
)
pbar
.
update
(
len
(
batch
))
return
results
\ No newline at end of file
mineru/utils/pdf_reader.py
View file @
4243b0ea
...
...
@@ -15,7 +15,7 @@ def page_to_image(
scale
=
dpi
/
72
long_side_length
=
max
(
*
page
.
get_size
())
if
long_side_length
>
max_width_or_height
:
if
(
long_side_length
*
scale
)
>
max_width_or_height
:
scale
=
max_width_or_height
/
long_side_length
bitmap
:
PdfBitmap
=
page
.
render
(
scale
=
scale
)
# type: ignore
...
...
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