From a4f33880298f213c15902dd2ddce4ee575a7e29d Mon Sep 17 00:00:00 2001 From: Sora <654163754@qq.com> Date: Wed, 6 Dec 2023 21:48:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20server=5Ffastapi.py.=20=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=96=87=E4=BB=B6=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E5=8A=A0=E8=BD=BD=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server_fastapi.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server_fastapi.py b/server_fastapi.py index 485b961..84e8765 100644 --- a/server_fastapi.py +++ b/server_fastapi.py @@ -87,6 +87,16 @@ class Models: :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():