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
a149a49c
Commit
a149a49c
authored
Jun 09, 2025
by
myhloli
Browse files
refactor: add local models directory handling and update config version
parent
14d268d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
magic-pdf.template.json
magic-pdf.template.json
+5
-1
mineru/utils/config_reader.py
mineru/utils/config_reader.py
+9
-1
mineru/utils/models_download_utils.py
mineru/utils/models_download_utils.py
+8
-0
No files found.
magic-pdf.template.json
View file @
a149a49c
...
...
@@ -21,5 +21,9 @@
"enable"
:
false
}
},
"config_version"
:
"1.2.2"
"models-dir"
:
{
"pipeline"
:
""
,
"vlm"
:
""
},
"config_version"
:
"1.3.0"
}
\ No newline at end of file
mineru/utils/config_reader.py
View file @
a149a49c
...
...
@@ -114,4 +114,12 @@ def get_llm_aided_config():
logger
.
warning
(
f
"'llm-aided-config' not found in
{
CONFIG_FILE_NAME
}
, use 'None' as default"
)
return
None
else
:
return
llm_aided_config
\ No newline at end of file
return
llm_aided_config
def
get_local_models_dir
():
config
=
read_config
()
models_dir
=
config
.
get
(
'models-dir'
)
if
models_dir
is
None
:
logger
.
warning
(
f
"'models-dir' not found in
{
CONFIG_FILE_NAME
}
, use None as default"
)
return
models_dir
\ No newline at end of file
mineru/utils/models_download_utils.py
View file @
a149a49c
...
...
@@ -2,6 +2,7 @@ import os
from
huggingface_hub
import
snapshot_download
as
hf_snapshot_download
from
modelscope
import
snapshot_download
as
ms_snapshot_download
from
mineru.utils.config_reader
import
get_local_models_dir
from
mineru.utils.enum_class
import
ModelPath
def
get_file_from_repos
(
relative_path
:
str
,
repo_mode
=
'pipeline'
)
->
str
:
...
...
@@ -15,6 +16,13 @@ def get_file_from_repos(relative_path: str, repo_mode='pipeline') -> str:
"""
model_source
=
os
.
getenv
(
'MINERU_MODEL_SOURCE'
,
None
)
if
model_source
==
'local'
:
local_models_config
=
get_local_models_dir
()
root_path
=
local_models_config
.
get
(
repo_mode
,
None
)
if
not
root_path
:
raise
ValueError
(
f
"Local path for repo_mode '
{
repo_mode
}
' is not configured."
)
return
os
.
path
.
join
(
root_path
,
relative_path
.
strip
(
'/'
))
# 建立仓库模式到路径的映射
repo_mapping
=
{
'pipeline'
:
{
...
...
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