settings.py中增加推理模型路径。

This commit is contained in:
zhanghuan
2025-09-10 15:12:45 +08:00
parent 5f62c6e2e0
commit 2412c26342
2 changed files with 5 additions and 1 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ from tkinterdnd2 import DND_FILES, TkinterDnD
import threading
import time
from net import create_food_cnn
from settings import settings
# 设置customtkinter的外观
ctk.set_appearance_mode("System")
@@ -54,7 +55,7 @@ class FoodClassifierApp:
def load_model(self):
"""加载训练好的PyTorch模型"""
try:
model_path = "../model/02/best_food_model.pth"
model_path = settings.INFERENCE_BEST_MODEL_PATH
if os.path.exists(model_path):
# 创建模型实例
self.model = create_food_cnn()
+3
View File
@@ -19,6 +19,9 @@ MODEL_DIR = os.path.join(BASE_DIR, 'model', '03')
BEST_MODEL_PATH = os.path.join(MODEL_DIR, 'best_food_model.pth')
TRAINING_CURVES_PATH = os.path.join(MODEL_DIR, 'training_curves.png')
# INFERENCE_BEST_MODEL_PATH = os.path.join(BASE_DIR, 'model', '03','best_food_model.pth')
INFERENCE_BEST_MODEL_PATH = BEST_MODEL_PATH
# 训练参数
# NUM_EPOCHS = 100
NUM_EPOCHS = 3