settings.py中增加推理模型路径。
This commit is contained in:
@@ -14,6 +14,7 @@ from tkinterdnd2 import DND_FILES, TkinterDnD
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from net import create_food_cnn
|
from net import create_food_cnn
|
||||||
|
from settings import settings
|
||||||
|
|
||||||
# 设置customtkinter的外观
|
# 设置customtkinter的外观
|
||||||
ctk.set_appearance_mode("System")
|
ctk.set_appearance_mode("System")
|
||||||
@@ -54,7 +55,7 @@ class FoodClassifierApp:
|
|||||||
def load_model(self):
|
def load_model(self):
|
||||||
"""加载训练好的PyTorch模型"""
|
"""加载训练好的PyTorch模型"""
|
||||||
try:
|
try:
|
||||||
model_path = "../model/02/best_food_model.pth"
|
model_path = settings.INFERENCE_BEST_MODEL_PATH
|
||||||
if os.path.exists(model_path):
|
if os.path.exists(model_path):
|
||||||
# 创建模型实例
|
# 创建模型实例
|
||||||
self.model = create_food_cnn()
|
self.model = create_food_cnn()
|
||||||
|
|||||||
@@ -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')
|
BEST_MODEL_PATH = os.path.join(MODEL_DIR, 'best_food_model.pth')
|
||||||
TRAINING_CURVES_PATH = os.path.join(MODEL_DIR, 'training_curves.png')
|
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 = 100
|
||||||
NUM_EPOCHS = 3
|
NUM_EPOCHS = 3
|
||||||
|
|||||||
Reference in New Issue
Block a user