support snapshot download from local (#153)

* support snapshot download from local

* let snapshot download from local
This commit is contained in:
KevinHuSh
2024-03-27 09:53:42 +08:00
committed by GitHub
parent da21320b88
commit 979b3a5b4b
12 changed files with 109 additions and 24 deletions

View File

@ -17,6 +17,7 @@ from copy import deepcopy
import onnxruntime as ort
from huggingface_hub import snapshot_download
from api.utils.file_utils import get_project_base_directory
from .operators import *
from rag.settings import cron_logger
@ -35,7 +36,15 @@ class Recognizer(object):
"""
if not model_dir:
model_dir = snapshot_download(repo_id="InfiniFlow/deepdoc")
try:
model_dir = snapshot_download(
repo_id="InfiniFlow/deepdoc",
local_dir=os.path.join(
get_project_base_directory(),
"rag/res/deepdoc"),
local_files_only=True)
except Exception as e:
model_dir = snapshot_download(repo_id="InfiniFlow/deepdoc")
model_file_path = os.path.join(model_dir, task_name + ".onnx")
if not os.path.exists(model_file_path):