Skip to content

Commit fa98cc2

Browse files
authored
Fix: add huggingface model download functionality (infiniflow#11101)
### What problem does this PR solve? reverse infiniflow#11048 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
1 parent c58d95e commit fa98cc2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

download_deps.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from typing import Union
1515

1616
import nltk
17+
from huggingface_hub import snapshot_download
1718

1819

1920
def get_urls(use_china_mirrors=False) -> list[Union[str, list[str]]]:
@@ -39,6 +40,19 @@ def get_urls(use_china_mirrors=False) -> list[Union[str, list[str]]]:
3940
]
4041

4142

43+
repos = [
44+
"InfiniFlow/text_concat_xgb_v1.0",
45+
"InfiniFlow/deepdoc",
46+
"InfiniFlow/huqie",
47+
]
48+
49+
50+
def download_model(repo_id):
51+
local_dir = os.path.abspath(os.path.join("huggingface.co", repo_id))
52+
os.makedirs(local_dir, exist_ok=True)
53+
snapshot_download(repo_id=repo_id, local_dir=local_dir)
54+
55+
4256
if __name__ == "__main__":
4357
parser = argparse.ArgumentParser(description="Download dependencies with optional China mirror support")
4458
parser.add_argument("--china-mirrors", action="store_true", help="Use China-accessible mirrors for downloads")
@@ -57,3 +71,7 @@ def get_urls(use_china_mirrors=False) -> list[Union[str, list[str]]]:
5771
for data in ["wordnet", "punkt", "punkt_tab"]:
5872
print(f"Downloading nltk {data}...")
5973
nltk.download(data, download_dir=local_dir)
74+
75+
for repo_id in repos:
76+
print(f"Downloading huggingface repo {repo_id}...")
77+
download_model(repo_id)

0 commit comments

Comments
 (0)