Skip to content

Commit

Permalink
Merge pull request #215 from jiangyuxiaoxiao/master
Browse files Browse the repository at this point in the history
update server_fastapi.py. 模型文件不存在时跳过加载模型
  • Loading branch information
jiangyuxiaoxiao authored Dec 6, 2023
2 parents c2fcc02 + a4f3388 commit 87462fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ def init_model(
:param device: 模型推理使用设备
:param language: 模型推理默认语言
"""
# 若文件不存在则不进行加载
if not os.path.isfile(model_path):
if model_path != "":
logger.warning(f"模型文件{model_path} 不存在,不进行初始化")
return self.num
if not os.path.isfile(config_path):
if config_path != "":
logger.warning(f"配置文件{config_path} 不存在,不进行初始化")
return self.num

# 若路径中的模型已存在,则不添加模型,若不存在,则进行初始化。
model_path = os.path.realpath(model_path)
if model_path not in self.path2ids.keys():
Expand Down

0 comments on commit 87462fe

Please sign in to comment.