You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB
Python

import pandas as pd
import numpy as np
from pathlib import Path
import joblib
# 直接测试模型加载功能
print("=== Direct Model Loading Test ===")
# 设置模型文件夹路径
model_folder = Path("./degree3")
print(f"Model folder path: {model_folder}")
print(f"Model folder exists: {model_folder.exists()}")
# 加载EV17.5相关的模型
try:
# 加载EV17.5_立焊模型
ev175_vertical_model_path = model_folder / "EV17.5_立焊.xlsx_model_degree3.pkl"
print(f"EV17.5_立焊 model path: {ev175_vertical_model_path}")
print(f"EV17.5_立焊 model exists: {ev175_vertical_model_path.exists()}")
if ev175_vertical_model_path.exists():
ev175_vertical_model = joblib.load(ev175_vertical_model_path)
print(f"EV17.5_立焊 model loaded successfully!")
# 测试模型预测
test_thickness = np.array([[9.0]])
prediction = ev175_vertical_model.predict(test_thickness)
print(f"EV17.5_立焊 prediction for thickness 9.0mm: {prediction}")
else:
print(f"EV17.5_立焊 model file not found!")
# 加载EV17.5_横焊模型
ev175_horizontal_model_path = model_folder / "EV17.5_横焊.xlsx_model_degree3.pkl"
print(f"\nEV17.5_横焊 model path: {ev175_horizontal_model_path}")
print(f"EV17.5_横焊 model exists: {ev175_horizontal_model_path.exists()}")
if ev175_horizontal_model_path.exists():
ev175_horizontal_model = joblib.load(ev175_horizontal_model_path)
print(f"EV17.5_横焊 model loaded successfully!")
# 测试模型预测
test_thickness = np.array([[9.0]])
prediction = ev175_horizontal_model.predict(test_thickness)
print(f"EV17.5_横焊 prediction for thickness 9.0mm: {prediction}")
else:
print(f"EV17.5_横焊 model file not found!")
except Exception as e:
print(f"Error during model loading or prediction: {e}")
import traceback
traceback.print_exc()