Update server_fastapi.py. Allowed to search models in "./" (#133)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
api服务 多版本多模型 fastapi实现
|
||||
"""
|
||||
import logging
|
||||
|
||||
import gc
|
||||
import utils
|
||||
from fastapi import FastAPI, Query
|
||||
from fastapi.responses import Response, FileResponse
|
||||
@@ -139,6 +139,7 @@ class Models:
|
||||
# 删除模型
|
||||
logger.success(f"卸载模型{model_path}, id = {index}")
|
||||
self.models.pop(index)
|
||||
gc.collect()
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.empty_cache()
|
||||
return index
|
||||
@@ -291,7 +292,7 @@ if __name__ == "__main__":
|
||||
|
||||
def _get_all_models(root_dir: str = "Data", only_unloaded: bool = False):
|
||||
result: Dict[str, List[str]] = dict()
|
||||
files = os.listdir(root_dir)
|
||||
files = os.listdir(root_dir) + ["."]
|
||||
for file in files:
|
||||
if os.path.isdir(os.path.join(root_dir, file)):
|
||||
sub_dir = os.path.join(root_dir, file)
|
||||
|
||||
Reference in New Issue
Block a user