|
|
|
|
@ -245,6 +245,14 @@ async def evaluate_model(request: Request, features_list: List[Features]):
|
|
|
|
|
abs_model_path = os.path.abspath(os.path.join(os.path.dirname(__file__), config["model_path"]))
|
|
|
|
|
config["model_path"] = abs_model_path
|
|
|
|
|
|
|
|
|
|
# 检查模型文件是否存在,如果不存在则复制模型文件
|
|
|
|
|
if not os.path.exists(config["model_path"]):
|
|
|
|
|
if not os.path.isabs(config['default_model_path']):
|
|
|
|
|
config['default_model_path'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), config['default_model_path'])
|
|
|
|
|
os.makedirs(os.path.dirname(config["model_path"]), exist_ok=True)
|
|
|
|
|
shutil.copyfile(config['default_model_path'], config["model_path"])
|
|
|
|
|
log_print(f"Model file not found. Copied default model from {config['default_model_path']} to {config['model_path']}")
|
|
|
|
|
|
|
|
|
|
# 配置日志
|
|
|
|
|
log_path = os.path.abspath(os.path.join(static_dir, f"evaluate_log_{now}.log"))
|
|
|
|
|
update_log_handler(log_path)
|
|
|
|
|
@ -324,6 +332,14 @@ async def inference_model(request: Request, features_list: List[Features]):
|
|
|
|
|
abs_model_path = os.path.abspath(os.path.join(os.path.dirname(__file__), config["model_path"]))
|
|
|
|
|
config["model_path"] = abs_model_path
|
|
|
|
|
|
|
|
|
|
# 检查模型文件是否存在,如果不存在则复制模型文件
|
|
|
|
|
if not os.path.exists(config["model_path"]):
|
|
|
|
|
if not os.path.isabs(config['default_model_path']):
|
|
|
|
|
config['default_model_path'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), config['default_model_path'])
|
|
|
|
|
os.makedirs(os.path.dirname(config["model_path"]), exist_ok=True)
|
|
|
|
|
shutil.copyfile(config['default_model_path'], config["model_path"])
|
|
|
|
|
log_print(f"Model file not found. Copied default model from {config['default_model_path']} to {config['model_path']}")
|
|
|
|
|
|
|
|
|
|
# 特征和标签
|
|
|
|
|
X = feature_label_weighted[config['feature_names']].values
|
|
|
|
|
|
|
|
|
|
|